@ -33,12 +33,9 @@
# include <QItemDelegate>
# include <QItemDelegate>
# include <QModelIndex>
# include <QModelIndex>
# include <QByteArray>
# include <QStyleOptionViewItem>
# include <QStyleOptionViewItemV2>
# include <QStyleOptionViewItemV2>
# include <QApplication>
# include <QApplication>
# include <QPainter>
# include <QPainter>
# include <QDateTime>
# include "misc.h"
# include "misc.h"
# include "torrentmodel.h"
# include "torrentmodel.h"
# include "qbtsession.h"
# include "qbtsession.h"
@ -133,12 +130,9 @@ public:
QItemDelegate : : drawBackground ( painter , opt , index ) ;
QItemDelegate : : drawBackground ( painter , opt , index ) ;
const qlonglong limit = index . data ( ) . toLongLong ( ) ;
const qlonglong limit = index . data ( ) . toLongLong ( ) ;
opt . displayAlignment = Qt : : AlignRight ;
opt . displayAlignment = Qt : : AlignRight ;
if ( limit > 0 )
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
* * but QString : : number ( 0.9999 * 100.0 , ' f ' , 1 ) = = 100.0 */
* * but QString : : number ( 0.9999 * 100.0 , ' f ' , 1 ) = = 100.0 */
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , limit > 0 ? QString : : number ( ( int ) ( ( limit / 1024. ) * 10 ) / 10.0 , ' f ' , 1 ) + " " + tr ( " KiB/s " , " KiB/second (.i.e per second) " ) : QString : : fromUtf8 ( " ∞ " ) ) ;
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , QString : : number ( ( int ) ( ( limit / 1024. ) * 10 ) / 10.0 , ' f ' , 1 ) + " " + tr ( " KiB/s " , " KiB/second (.i.e per second) " ) ) ;
else
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , QString : : fromUtf8 ( " ∞ " ) ) ;
break ;
break ;
}
}
case TorrentModelItem : : TR_TIME_ELAPSED : {
case TorrentModelItem : : TR_TIME_ELAPSED : {
@ -159,12 +153,9 @@ public:
QItemDelegate : : drawBackground ( painter , opt , index ) ;
QItemDelegate : : drawBackground ( painter , opt , index ) ;
opt . displayAlignment = Qt : : AlignRight ;
opt . displayAlignment = Qt : : AlignRight ;
const qreal ratio = index . data ( ) . toDouble ( ) ;
const qreal ratio = index . data ( ) . toDouble ( ) ;
if ( ratio > QBtSession : : MAX_RATIO )
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , QString : : fromUtf8 ( " ∞ " ) ) ;
* * but QString : : number ( 0.9999 * 100.0 , ' f ' , 1 ) = = 100.0 */
else
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , ratio > QBtSession : : MAX_RATIO ? QString : : fromUtf8 ( " ∞ " ) : QString : : number ( ( int ) ( ratio * 100 ) / 100.0 , ' f ' , 2 ) ) ;
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
* * but QString : : number ( 0.9999 * 100.0 , ' f ' , 1 ) = = 100.0 */
QItemDelegate : : drawDisplay ( painter , opt , opt . rect , QString : : number ( ( int ) ( ratio * 100 ) / 100.0 , ' f ' , 2 ) ) ;
break ;
break ;
}
}
case TorrentModelItem : : TR_PRIORITY : {
case TorrentModelItem : : TR_PRIORITY : {