mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 04:10:20 +02:00
* Properly calculate JobStatusItem's row height, taking current font settings into account.
This commit is contained in:
@@ -19,13 +19,14 @@
|
|||||||
#include "JobStatusDelegate.h"
|
#include "JobStatusDelegate.h"
|
||||||
|
|
||||||
#include "JobStatusModel.h"
|
#include "JobStatusModel.h"
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
|
|
||||||
#define ROW_HEIGHT 20
|
#define ROW_HEIGHT ( TomahawkUtils::defaultFontHeight() + 6 )
|
||||||
#define ICON_PADDING 2
|
#define ICON_PADDING 2
|
||||||
#define PADDING 2
|
#define PADDING 2
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
rightEdge = rRect.left();
|
rightEdge = rRect.left();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int mainW = rightEdge - 4 * PADDING - iconRect.right();
|
const int mainW = rightEdge - 6 * PADDING - iconRect.right();
|
||||||
QString mainText = index.data( Qt::DisplayRole ).toString();
|
QString mainText = index.data( Qt::DisplayRole ).toString();
|
||||||
QTextOption to( Qt::AlignLeft | Qt::AlignVCenter );
|
QTextOption to( Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
if ( !allowMultiLine )
|
if ( !allowMultiLine )
|
||||||
@@ -98,9 +99,9 @@ JobStatusDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelInd
|
|||||||
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
||||||
|
|
||||||
if ( !allowMultiLine )
|
if ( !allowMultiLine )
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
return QSize( QStyledItemDelegate::sizeHint( option, index ).width(), ROW_HEIGHT );
|
||||||
else if ( m_cachedMultiLineHeights.contains( index ) )
|
else if ( m_cachedMultiLineHeights.contains( index ) )
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), m_cachedMultiLineHeights[ index ] );
|
return QSize( QStyledItemDelegate::sizeHint( option, index ).width(), m_cachedMultiLineHeights[ index ] );
|
||||||
|
|
||||||
// Don't elide, but stretch across as many rows as required
|
// Don't elide, but stretch across as many rows as required
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
Reference in New Issue
Block a user