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()