Skip to content

Commit

Permalink
Removed unused columns completely (bsc#1182555)
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Feb 22, 2021
1 parent 79f6ede commit 98ab299
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
39 changes: 14 additions & 25 deletions src/QY2DiskUsageList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
**/
QColor
contrastingColor( const QColor & desiredColor,
const QColor & contrastColor )
const QColor & contrastColor )
{
if ( desiredColor != contrastColor )
{
Expand Down Expand Up @@ -126,8 +126,8 @@ interpolateColor( int val,
maxColor.getHsv( &maxH, &maxS, &maxV );

return QColor::fromHsv( interpolate( val, minVal, maxVal, minH, maxH ),
interpolate( val, minVal, maxVal, minS, maxS ),
interpolate( val, minVal, maxVal, minV, maxV ) );
interpolate( val, minVal, maxVal, minS, maxS ),
interpolate( val, minVal, maxVal, minV, maxV ) );
}


Expand Down Expand Up @@ -212,7 +212,9 @@ QY2DiskUsageList::~QY2DiskUsageList()
}


void QY2DiskUsageList::drawRow( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
void QY2DiskUsageList::drawRow( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
{
// Intentionally bypassing the direct parent class method, use the grandparent's:
// Don't let QY2ListViewItem::_textColor / _backgroundColor interfere with our colors.
Expand All @@ -221,44 +223,38 @@ void QY2DiskUsageList::drawRow( QPainter * painter, const QStyleOptionViewItem &
}




QY2DiskUsageListItem::QY2DiskUsageListItem( QY2DiskUsageList * parent )
: QY2ListViewItem( parent )
, _diskUsageList( parent )
{
}




QY2DiskUsageListItem::~QY2DiskUsageListItem()
{
// NOP
}




void
QY2DiskUsageListItem::init( bool allFields )
{
setSizeHint( percentageBarCol(), QSize( 20, 10 ) );

setTextAlignment( usedSizeCol(), Qt::AlignRight );
setTextAlignment( freeSizeCol(), Qt::AlignRight );
setTextAlignment( totalSizeCol(), Qt::AlignRight );

if ( usedSizeCol() >= 0 ) setText( usedSizeCol(), usedSize() );
if ( freeSizeCol() >= 0 ) setText( freeSizeCol(), freeSize() );
if ( freeSizeCol() >= 0 ) setText( freeSizeCol(), freeSize() );

if ( allFields )
{
if ( totalSizeCol() >= 0 ) setText( totalSizeCol(), totalSize() );
if ( nameCol() >= 0 ) setText( nameCol(), name() );
if ( deviceNameCol() >= 0 ) setText( deviceNameCol(), deviceName() );
if ( totalSizeCol() >= 0 ) setText( totalSizeCol(), totalSize() );
if ( nameCol() >= 0 ) setText( nameCol(), name() );
}

if ( usedSizeCol() < 0 )
setToolTip( freeSizeCol(), _( "Used %1" ).arg( usedSize().form( 0, 1, true ).c_str() ) );
setToolTip( freeSizeCol(), _( "Used %1" ).arg( usedSize().form( 0, 1, true ).c_str() ) );
}


Expand Down Expand Up @@ -303,9 +299,6 @@ QY2DiskUsageListItem::updateData()
}





/**
* Comparison function used for sorting the list.
* Reimplemented from QTreeWidgetItem
Expand All @@ -323,10 +316,6 @@ QY2DiskUsageListItem::operator<( const QTreeWidgetItem & otherListViewItem ) con
// Intentionally reverting sort order: Fullest first
return ( this->usedPercent() < other->usedPercent() );
}
else if ( col == usedSizeCol() )
{
return ( this->usedSize() < other->usedSize() );
}
else if ( col == freeSizeCol() )
{
return ( this->freeSize() < other->freeSize() );
Expand All @@ -353,8 +342,8 @@ QY2DiskUsageListItem::paintPercentageBar( QPainter * painter,
if ( percent > 100.0 ) percent = 100.0;
if ( percent < 0.0 ) percent = 0.0;
int x = option.rect.left() + 1;
int y = option.rect.top() + 1;
int w = option.rect.width() - 2;
int y = option.rect.top() + 1;
int w = option.rect.width() - 2;
int h = option.rect.height() - 2;
int fillWidth = 0;

Expand Down
17 changes: 6 additions & 11 deletions src/QY2DiskUsageList.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,24 @@ class QY2DiskUsageList : public QY2ListView

int nameCol() const { return _nameCol; }
int percentageBarCol() const { return _percentageBarCol; }
int usedSizeCol() const { return _usedSizeCol; }
int freeSizeCol() const { return _freeSizeCol; }
int totalSizeCol() const { return _totalSizeCol; }
int deviceNameCol() const { return _deviceNameCol; }


virtual void drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
virtual void drawRow ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const;

// make it public
// Reimplemented to make this public for use in the QItemDelegate
QTreeWidgetItem * itemFromIndex ( const QModelIndex & index ) const
{ return QY2ListView::itemFromIndex(index); }
{ return QY2ListView::itemFromIndex(index); }

protected:

int _nameCol;
int _percentageBarCol;
int _usedSizeCol;
int _freeSizeCol;
int _totalSizeCol;
int _deviceNameCol;
};


Expand All @@ -107,7 +105,6 @@ class QY2DiskUsageListItem: public QY2ListViewItem
**/
QY2DiskUsageListItem( QY2DiskUsageList * parent );


/**
* Destructor.
**/
Expand Down Expand Up @@ -197,18 +194,16 @@ class QY2DiskUsageListItem: public QY2ListViewItem

/**
* Comparison function used for sorting the list.
* Reimplemented from QTreeWidgetItem
* Reimplemented from QTreeWidgetItem.
**/
virtual bool operator< ( const QTreeWidgetItem & other ) const;

// Columns

int nameCol() const { return _diskUsageList->nameCol(); }
int percentageBarCol() const { return _diskUsageList->percentageBarCol(); }
int usedSizeCol() const { return _diskUsageList->usedSizeCol(); }
int freeSizeCol() const { return _diskUsageList->freeSizeCol(); }
int totalSizeCol() const { return _diskUsageList->totalSizeCol(); }
int deviceNameCol() const { return _diskUsageList->deviceNameCol(); }


protected:
Expand Down

0 comments on commit 98ab299

Please sign in to comment.