Browse Source

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

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
22d9427e20
  1. 11
      src/gui/previewselect.cpp
  2. 13
      src/gui/properties/trackerlist.cpp
  3. 15
      src/gui/torrentcontenttreeview.cpp
  4. 12
      src/gui/transferlistwidget.cpp
  5. 11
      src/searchengine/engineselectdlg.cpp
  6. 11
      src/searchengine/searchtab.cpp

11
src/gui/previewselect.cpp

@ -32,6 +32,9 @@
#include <QHeaderView> #include <QHeaderView>
#include <QMessageBox> #include <QMessageBox>
#include <QFile> #include <QFile>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
#include "core/utils/misc.h" #include "core/utils/misc.h"
#include "previewlistdelegate.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(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); 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->setModel(previewListModel);
previewList->hideColumn(FILE_INDEX); previewList->hideColumn(FILE_INDEX);
listDelegate = new PreviewListDelegate(this); listDelegate = new PreviewListDelegate(this);

13
src/gui/properties/trackerlist.cpp

@ -37,6 +37,10 @@
#include <QDebug> #include <QDebug>
#include <QUrl> #include <QUrl>
#include <QMessageBox> #include <QMessageBox>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#include <QHeaderView>
#endif
#include "core/bittorrent/session.h" #include "core/bittorrent/session.h"
#include "core/bittorrent/torrenthandle.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); 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); 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(); loadSettings();
} }

15
src/gui/torrentcontenttreeview.cpp

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

12
src/gui/transferlistwidget.cpp

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

11
src/searchengine/engineselectdlg.cpp

@ -47,6 +47,9 @@
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QMimeData> #include <QMimeData>
#include <QClipboard> #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}; 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); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); 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->setRootIsDecorated(false);
pluginsTree->header()->resizeSection(0, 160); pluginsTree->header()->resizeSection(0, 160);
pluginsTree->header()->resizeSection(1, 80); pluginsTree->header()->resizeSection(1, 80);

11
src/searchengine/searchtab.cpp

@ -33,6 +33,9 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QHeaderView> #include <QHeaderView>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QTableView>
#endif
#include "searchtab.h" #include "searchtab.h"
#include "searchlistdelegate.h" #include "searchlistdelegate.h"
@ -45,6 +48,14 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
box = new QVBoxLayout(); box = new QVBoxLayout();
results_lbl = new QLabel(); results_lbl = new QLabel();
resultsBrowser = new QTreeView(); 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); resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
box->addWidget(results_lbl); box->addWidget(results_lbl);
box->addWidget(resultsBrowser); box->addWidget(resultsBrowser);

Loading…
Cancel
Save