mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 14:23:35 -07:00
Apply suggestions from code review
Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This commit is contained in:
parent
d75c8d1cbd
commit
c4629a4e57
4 changed files with 67 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue