Fix reordering of first column with Qt5. Closes #2835.

This commit is contained in:
sledgehammer999 2015-11-18 18:13:25 +02:00
parent 2e3cce6755
commit 22d9427e20
6 changed files with 72 additions and 1 deletions

View file

@ -32,6 +32,9 @@
#include <QHeaderView>
#include <QMessageBox>
#include <QFile>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
#include "core/utils/misc.h"
#include "previewlistdelegate.h"
@ -51,6 +54,14 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(previewList->header());
previewList->header()->setParent(previewList);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
previewList->setModel(previewListModel);
previewList->hideColumn(FILE_INDEX);
listDelegate = new PreviewListDelegate(this);

View file

@ -37,6 +37,10 @@
#include <QDebug>
#include <QUrl>
#include <QMessageBox>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#include <QHeaderView>
#endif
#include "core/bittorrent/session.h"
#include "core/bittorrent/torrenthandle.h"
@ -81,6 +85,15 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
copyHotkey = new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_C), this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// 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));
#endif
loadSettings();
}

View file

@ -32,12 +32,25 @@
#include <QKeyEvent>
#include <QModelIndexList>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#include <QHeaderView>
#endif
#include "torrentcontentmodelitem.h"
TorrentContentTreeView::TorrentContentTreeView(QWidget* parent)
: QTreeView(parent)
{}
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// 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));
#endif
}
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) {
if (event->key() != Qt::Key_Space && event->key() != Qt::Key_Select) {

View file

@ -40,6 +40,9 @@
#include <QRegExp>
#include <QFileDialog>
#include <QMessageBox>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
#include "transferlistwidget.h"
#include "core/bittorrent/session.h"
@ -152,6 +155,15 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window)
editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut);
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// 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));
#endif
}
TransferListWidget::~TransferListWidget()

View file

@ -47,6 +47,9 @@
#include <QTemporaryFile>
#include <QMimeData>
#include <QClipboard>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
enum EngineColumns {ENGINE_NAME, ENGINE_VERSION, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
@ -57,6 +60,14 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(pluginsTree->header());
pluginsTree->header()->setParent(pluginsTree);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
pluginsTree->setRootIsDecorated(false);
pluginsTree->header()->resizeSection(0, 160);
pluginsTree->header()->resizeSection(1, 80);

View file

@ -33,6 +33,9 @@
#include <QStandardItemModel>
#include <QHeaderView>
#include <QSortFilterProxyModel>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
#include "searchtab.h"
#include "searchlistdelegate.h"
@ -45,6 +48,14 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
box = new QVBoxLayout();
results_lbl = new QLabel();
resultsBrowser = new QTreeView();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(resultsBrowser->header());
resultsBrowser->header()->setParent(resultsBrowser);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
box->addWidget(results_lbl);
box->addWidget(resultsBrowser);