From 525571966142c36b870f3adaa1f680c7d368fbec Mon Sep 17 00:00:00 2001 From: thalieht Date: Thu, 16 Jun 2016 21:44:33 +0300 Subject: [PATCH] SearchTab: align text to the right in columns that handle numbers --- src/gui/search/searchlistdelegate.cpp | 3 +++ src/gui/search/searchtab.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/gui/search/searchlistdelegate.cpp b/src/gui/search/searchlistdelegate.cpp index 646eb8344..dc286f5d9 100644 --- a/src/gui/search/searchlistdelegate.cpp +++ b/src/gui/search/searchlistdelegate.cpp @@ -50,14 +50,17 @@ void SearchListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op switch(index.column()) { case SearchSortModel::SIZE: QItemDelegate::drawBackground(painter, opt, index); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); break; case SearchSortModel::SEEDS: QItemDelegate::drawBackground(painter, opt, index); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, option.rect, (index.data().toLongLong() >= 0) ? index.data().toString() : tr("Unknown")); break; case SearchSortModel::LEECHES: QItemDelegate::drawBackground(painter, opt, index); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, option.rect, (index.data().toLongLong() >= 0) ? index.data().toString() : tr("Unknown")); break; default: diff --git a/src/gui/search/searchtab.cpp b/src/gui/search/searchtab.cpp index df86ebb84..819789770 100644 --- a/src/gui/search/searchtab.cpp +++ b/src/gui/search/searchtab.cpp @@ -83,6 +83,10 @@ SearchTab::SearchTab(SearchWidget *parent) m_searchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources")); m_searchListModel->setHeaderData(SearchSortModel::LEECHES, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources")); m_searchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine")); + // Set columns text alignment + m_searchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole); + m_searchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole); + m_searchListModel->setHeaderData(SearchSortModel::LEECHES, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole); m_proxyModel = new SearchSortModel(this); m_proxyModel->setDynamicSortFilter(true);