Commit 3fd0e736 authored by Kevin Kofler's avatar Kevin Kofler
Browse files

Kompare: Provide a default implementation of KompareListViewItem::paintCell...

Kompare: Provide a default implementation of KompareListViewItem::paintCell which does the zero-height case (reduces code duplication).

svn path=/trunk/KDE/kdesdk/kompare/; revision=1262755
parent 5916adf8
......@@ -593,6 +593,18 @@ KompareListView* KompareListViewItem::kompareListView() const
return (KompareListView*)treeWidget();
}
void KompareListViewItem::paintCell( QPainter* p, const QStyleOptionViewItem& option, int column )
{
// Default implementation for zero-height items.
// We have to paint the item which shines through or we'll end up with glitches.
KompareListViewItem* nextItem = (KompareListViewItem*)kompareListView()->itemBelow(this);
if( nextItem ) {
QStyleOptionViewItemV4 changedOption = option;
changedOption.rect.translate( 0, height() );
nextItem->paintCell( p, changedOption, column );
}
}
KompareListViewDiffItem::KompareListViewDiffItem( KompareListView* parent, Difference* difference )
: KompareListViewItem( parent, Diff ),
m_difference( difference ),
......@@ -650,17 +662,6 @@ int KompareListViewDiffItem::maxHeight()
return lines * treeWidget()->fontMetrics().height();
}
void KompareListViewDiffItem::paintCell( QPainter* p, const QStyleOptionViewItem& option, int column )
{
// We have to paint the item which shines through or we'll end up with glitches.
KompareListViewItem* nextItem = (KompareListViewItem*)kompareListView()->itemBelow(this);
if( nextItem ) {
QStyleOptionViewItemV4 changedOption = option;
changedOption.rect.translate( 0, height() );
nextItem->paintCell( p, changedOption, column );
}
}
KompareListViewLineContainerItem::KompareListViewLineContainerItem( KompareListViewDiffItem* parent, bool isSource )
: KompareListViewItem( parent, Container ),
m_blankLineItem( 0 ),
......@@ -712,17 +713,6 @@ DifferenceString* KompareListViewLineContainerItem::lineAt( int i ) const
diffItemParent()->difference()->destinationLineAt( i );
}
void KompareListViewLineContainerItem::paintCell( QPainter* p, const QStyleOptionViewItem& option, int column )
{
// We have to paint the item which shines through or we'll end up with glitches.
KompareListViewItem* nextItem = (KompareListViewItem*)kompareListView()->itemBelow(this);
if( nextItem ) {
QStyleOptionViewItemV4 changedOption = option;
changedOption.rect.translate( 0, height() );
nextItem->paintCell( p, changedOption, column );
}
}
KompareListViewLineItem::KompareListViewLineItem( KompareListViewLineContainerItem* parent, int line, DifferenceString* text )
: KompareListViewItem( parent, Line )
{
......@@ -952,13 +942,7 @@ int KompareListViewHunkItem::maxHeight()
void KompareListViewHunkItem::paintCell( QPainter* p, const QStyleOptionViewItem& option, int column )
{
if( m_zeroHeight ) {
// We have to paint the item which shines through or we'll end up with glitches.
KompareListViewItem* nextItem = (KompareListViewItem*)kompareListView()->itemBelow(this);
if( nextItem ) {
QStyleOptionViewItemV4 changedOption = option;
changedOption.rect.translate( 0, height() );
nextItem->paintCell( p, changedOption, column );
}
KompareListViewItem::paintCell( p, option, column );
} else {
int x = option.rect.left();
int y = option.rect.top() - paintOffset();
......
......@@ -149,7 +149,7 @@ public:
KompareListViewItem( KompareListViewItem* parent, int type );
KompareListViewItem( KompareListViewItem* parent, KompareListViewItem* after, int type );
virtual void paintCell( QPainter* p, const QStyleOptionViewItem& option, int column ) = 0;
virtual void paintCell( QPainter* p, const QStyleOptionViewItem& option, int column );
void repaint();
int height() const;
......@@ -185,8 +185,6 @@ public:
virtual int maxHeight();
virtual void paintCell( QPainter* p, const QStyleOptionViewItem& option, int column );
private:
void init();
void setVisibility();
......@@ -208,8 +206,6 @@ public:
virtual int maxHeight() { return 0; }
virtual void paintCell( QPainter* p, const QStyleOptionViewItem& option, int column );
KompareListViewDiffItem* diffItemParent() const;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment