Apply suggestions from code review

Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This commit is contained in:
Luke Memet 2025-02-15 13:01:19 -05:00 committed by GitHub
commit c4629a4e57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 20 deletions

View file

@ -1,13 +1,41 @@
#include "macosshiftclickhandler.h"
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2025 Your_Name_Or_Nick <your_email@example.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "macosshiftclickhandler.h"
#include <QMouseEvent>
#include "transferlistwidget.h"
MacOSShiftClickHandler::MacOSShiftClickHandler(TransferListWidget *parent)
: QObject(parent)
, m_treeView(parent)
MacOSShiftClickHandler::MacOSShiftClickHandler(TransferListWidget *treeView)
: QObject(treeView)
, m_treeView {treeView}
{
parent->installEventFilter(this);
treeView->installEventFilter(this);
}
bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
@ -42,4 +70,4 @@ bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
}
return false;
}
}

View file

@ -1,3 +1,31 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2025 Your_Name_Or_Nick <your_email@example.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#pragma once
#include <QObject>
@ -12,12 +40,11 @@ class MacOSShiftClickHandler final : public QObject
Q_DISABLE_COPY_MOVE(MacOSShiftClickHandler)
public:
explicit MacOSShiftClickHandler(TransferListWidget *parent);
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
explicit MacOSShiftClickHandler(TransferListWidget *treeView);
private:
bool eventFilter(QObject *watched, QEvent *event) override;
TransferListWidget *m_treeView;
QPersistentModelIndex m_lastClickedIndex;
};
};

View file

@ -159,7 +159,7 @@ TransferListWidget::TransferListWidget(IGUIApplication *app, QWidget *parent)
setDropIndicatorShown(true);
#if defined(Q_OS_MACOS)
setAttribute(Qt::WA_MacShowFocusRect, false);
m_shiftClickHandler = new MacOSShiftClickHandler(this);
new MacOSShiftClickHandler(this);
#endif
header()->setFirstSectionMovable(true);
header()->setStretchLastSection(false);

View file

@ -52,10 +52,6 @@ enum class CopyInfohashPolicy
Version2
};
#ifdef Q_OS_MACOS
class MacOSShiftClickHandler; // Forward declaration
#endif
class TransferListWidget final : public GUIApplicationComponent<QTreeView>
{
Q_OBJECT
@ -141,10 +137,6 @@ private:
QList<BitTorrent::Torrent *> getVisibleTorrents() const;
int visibleColumnsCount() const;
#ifdef Q_OS_MACOS
MacOSShiftClickHandler *m_shiftClickHandler = nullptr;
#endif
TransferListModel *m_listModel = nullptr;
TransferListSortModel *m_sortFilterModel = nullptr;
};