Browse Source

Don't use hack to make the first column movable

PR #16545.
adaptive-webui-19844
thalieht 3 years ago committed by GitHub
parent
commit
63812ca951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/gui/previewselectdialog.cpp
  2. 9
      src/gui/properties/peerlistwidget.cpp
  3. 9
      src/gui/properties/trackerlistwidget.cpp
  4. 9
      src/gui/search/pluginselectdialog.cpp
  5. 9
      src/gui/search/searchjobwidget.cpp
  6. 11
      src/gui/torrentcontenttreeview.cpp
  7. 9
      src/gui/transferlistwidget.cpp

9
src/gui/previewselectdialog.cpp

@ -37,7 +37,6 @@
#include <QPushButton> #include <QPushButton>
#include <QShowEvent> #include <QShowEvent>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTableView>
#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrent.h"
#include "base/preferences.h" #include "base/preferences.h"
@ -77,13 +76,6 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
m_previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); m_previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
m_previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); m_previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->previewList->header());
m_ui->previewList->header()->setParent(m_ui->previewList);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
m_ui->previewList->setAlternatingRowColors(pref->useAlternatingRowColors()); m_ui->previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
m_ui->previewList->setModel(m_previewListModel); m_ui->previewList->setModel(m_previewListModel);
m_ui->previewList->hideColumn(FILE_INDEX); m_ui->previewList->hideColumn(FILE_INDEX);
@ -107,6 +99,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
m_previewListModel->sort(NAME); m_previewListModel->sort(NAME);
m_ui->previewList->header()->setContextMenuPolicy(Qt::CustomContextMenu); m_ui->previewList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
m_ui->previewList->header()->setFirstSectionMovable(true);
m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder); m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
m_ui->previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows); m_ui->previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);

9
src/gui/properties/peerlistwidget.cpp

@ -40,7 +40,6 @@
#include <QShortcut> #include <QShortcut>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTableView>
#include <QVector> #include <QVector>
#include <QWheelEvent> #include <QWheelEvent>
@ -89,6 +88,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
setEditTriggers(QAbstractItemView::NoEditTriggers); setEditTriggers(QAbstractItemView::NoEditTriggers);
setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
header()->setFirstSectionMovable(true);
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
header()->setTextElideMode(Qt::ElideRight); header()->setTextElideMode(Qt::ElideRight);
@ -163,13 +163,6 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
handleSortColumnChanged(header()->sortIndicatorSection()); handleSortColumnChanged(header()->sortIndicatorSection());
const auto *copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers); connect(copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(this->header());
this->header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
} }
PeerListWidget::~PeerListWidget() PeerListWidget::~PeerListWidget()

9
src/gui/properties/trackerlistwidget.cpp

@ -38,7 +38,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QShortcut> #include <QShortcut>
#include <QStringList> #include <QStringList>
#include <QTableView>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QUrl> #include <QUrl>
#include <QVector> #include <QVector>
@ -70,6 +69,7 @@ TrackerListWidget::TrackerListWidget(PropertiesWidget *properties)
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
setItemsExpandable(false); setItemsExpandable(false);
setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
header()->setFirstSectionMovable(true);
header()->setStretchLastSection(false); // Must be set after loadSettings() in order to work header()->setStretchLastSection(false); // Must be set after loadSettings() in order to work
header()->setTextElideMode(Qt::ElideRight); header()->setTextElideMode(Qt::ElideRight);
// Ensure that at least one column is visible at all times // Ensure that at least one column is visible at all times
@ -133,13 +133,6 @@ TrackerListWidget::TrackerListWidget(PropertiesWidget *properties)
connect(copyHotkey, &QShortcut::activated, this, &TrackerListWidget::copyTrackerUrl); connect(copyHotkey, &QShortcut::activated, this, &TrackerListWidget::copyTrackerUrl);
connect(this, &QAbstractItemView::doubleClicked, this, &TrackerListWidget::editSelectedTracker); connect(this, &QAbstractItemView::doubleClicked, this, &TrackerListWidget::editSelectedTracker);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
} }
TrackerListWidget::~TrackerListWidget() TrackerListWidget::~TrackerListWidget()

9
src/gui/search/pluginselectdialog.cpp

@ -37,7 +37,6 @@
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QMimeData> #include <QMimeData>
#include <QTableView>
#include "base/global.h" #include "base/global.h"
#include "base/net/downloadmanager.h" #include "base/net/downloadmanager.h"
@ -69,15 +68,9 @@ PluginSelectDialog::PluginSelectDialog(SearchPluginManager *pluginManager, QWidg
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->pluginsTree->header());
m_ui->pluginsTree->header()->setParent(m_ui->pluginsTree);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
m_ui->pluginsTree->setRootIsDecorated(false); m_ui->pluginsTree->setRootIsDecorated(false);
m_ui->pluginsTree->hideColumn(PLUGIN_ID); m_ui->pluginsTree->hideColumn(PLUGIN_ID);
m_ui->pluginsTree->header()->setFirstSectionMovable(true);
m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder); m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder);
m_ui->actionUninstall->setIcon(UIThemeManager::instance()->getIcon("list-remove")); m_ui->actionUninstall->setIcon(UIThemeManager::instance()->getIcon("list-remove"));

9
src/gui/search/searchjobwidget.cpp

@ -37,7 +37,6 @@
#include <QMenu> #include <QMenu>
#include <QPalette> #include <QPalette>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTableView>
#include <QUrl> #include <QUrl>
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
@ -61,15 +60,9 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->resultsBrowser->header());
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
loadSettings(); loadSettings();
header()->setFirstSectionMovable(true);
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
header()->setTextElideMode(Qt::ElideRight); header()->setTextElideMode(Qt::ElideRight);

11
src/gui/torrentcontenttreeview.cpp

@ -34,7 +34,6 @@
#include <QLineEdit> #include <QLineEdit>
#include <QMessageBox> #include <QMessageBox>
#include <QModelIndexList> #include <QModelIndexList>
#include <QTableView>
#include <QThread> #include <QThread>
#include "base/bittorrent/abstractfilestorage.h" #include "base/bittorrent/abstractfilestorage.h"
@ -66,15 +65,7 @@ TorrentContentTreeView::TorrentContentTreeView(QWidget *parent)
: QTreeView(parent) : QTreeView(parent)
{ {
setExpandsOnDoubleClick(false); setExpandsOnDoubleClick(false);
header()->setFirstSectionMovable(true);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
header()->setStretchLastSection(false);
header()->setTextElideMode(Qt::ElideRight);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
} }
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) void TorrentContentTreeView::keyPressEvent(QKeyEvent *event)

9
src/gui/transferlistwidget.cpp

@ -39,7 +39,6 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QSet> #include <QSet>
#include <QShortcut> #include <QShortcut>
#include <QTableView>
#include <QVector> #include <QVector>
#include <QWheelEvent> #include <QWheelEvent>
@ -152,6 +151,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
setAttribute(Qt::WA_MacShowFocusRect, false); setAttribute(Qt::WA_MacShowFocusRect, false);
#endif #endif
header()->setFirstSectionMovable(true);
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
header()->setTextElideMode(Qt::ElideRight); header()->setTextElideMode(Qt::ElideRight);
@ -222,13 +222,6 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents); connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
} }
TransferListWidget::~TransferListWidget() TransferListWidget::~TransferListWidget()

Loading…
Cancel
Save