@ -59,24 +59,24 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
@@ -59,24 +59,24 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
// tabBottom->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/oxygen/filter.png")));
// Set Download list model
src Model = new QStandardItemModel ( 0 , 10 ) ;
src Model- > setHeaderData ( NAME , Qt : : Horizontal , tr ( " Name " , " i.e: file name " ) ) ;
src Model- > setHeaderData ( SIZE , Qt : : Horizontal , tr ( " Size " , " i.e: file size " ) ) ;
src Model- > setHeaderData ( PROGRESS , Qt : : Horizontal , tr ( " Progress " , " i.e: % downloaded " ) ) ;
src Model- > setHeaderData ( DLSPEED , Qt : : Horizontal , tr ( " DL Speed " , " i.e: Download speed " ) ) ;
src Model- > setHeaderData ( UPSPEED , Qt : : Horizontal , tr ( " UP Speed " , " i.e: Upload speed " ) ) ;
src Model- > setHeaderData ( SEEDSLEECH , Qt : : Horizontal , tr ( " Seeds/Leechers " , " i.e: full/partial sources " ) ) ;
src Model- > setHeaderData ( RATIO , Qt : : Horizontal , tr ( " Ratio " ) ) ;
src Model- > setHeaderData ( ETA , Qt : : Horizontal , tr ( " ETA " , " i.e: Estimated Time of Arrival / Time left " ) ) ;
src Model- > setHeaderData ( PRIORITY , Qt : : Horizontal , " # " ) ;
DLList Model = new QStandardItemModel ( 0 , 10 ) ;
DLList Model- > setHeaderData ( NAME , Qt : : Horizontal , tr ( " Name " , " i.e: file name " ) ) ;
DLList Model- > setHeaderData ( SIZE , Qt : : Horizontal , tr ( " Size " , " i.e: file size " ) ) ;
DLList Model- > setHeaderData ( PROGRESS , Qt : : Horizontal , tr ( " Progress " , " i.e: % downloaded " ) ) ;
DLList Model- > setHeaderData ( DLSPEED , Qt : : Horizontal , tr ( " DL Speed " , " i.e: Download speed " ) ) ;
DLList Model- > setHeaderData ( UPSPEED , Qt : : Horizontal , tr ( " UP Speed " , " i.e: Upload speed " ) ) ;
DLList Model- > setHeaderData ( SEEDSLEECH , Qt : : Horizontal , tr ( " Seeds/Leechers " , " i.e: full/partial sources " ) ) ;
DLList Model- > setHeaderData ( RATIO , Qt : : Horizontal , tr ( " Ratio " ) ) ;
DLList Model- > setHeaderData ( ETA , Qt : : Horizontal , tr ( " ETA " , " i.e: Estimated Time of Arrival / Time left " ) ) ;
DLList Model- > setHeaderData ( PRIORITY , Qt : : Horizontal , " # " ) ;
downloadList - > setRootIsDecorated ( false ) ;
downloadList - > setAllColumnsShowFocus ( true ) ;
DLDelegate = new DLListDelegate ( downloadList ) ;
downloadList - > setItemDelegate ( DLDelegate ) ;
DLList Model = new QSortFilterProxyModel ( ) ;
DLList Model- > setDynamicSortFilter ( true ) ;
DLList Model- > setSourceModel ( src Model) ;
downloadList - > setModel ( DLList Model) ;
proxy Model = new QSortFilterProxyModel ( ) ;
proxy Model- > setDynamicSortFilter ( true ) ;
proxy Model- > setSourceModel ( DLList Model) ;
downloadList - > setModel ( proxy Model) ;
downloadList - > setSortingEnabled ( true ) ;
// Hide priority column
downloadList - > hideColumn ( PRIORITY ) ;
@ -134,8 +134,8 @@ DownloadingTorrents::~DownloadingTorrents() {
@@ -134,8 +134,8 @@ DownloadingTorrents::~DownloadingTorrents() {
saveColWidthDLList ( ) ;
saveHiddenColumns ( ) ;
delete DLDelegate ;
delete src Model;
delete src Model;
delete proxy Model;
delete DLList Model;
}
void DownloadingTorrents : : enablePriorityColumn ( bool enable ) {
@ -161,13 +161,13 @@ void DownloadingTorrents::pauseTorrent(QString hash) {
@@ -161,13 +161,13 @@ void DownloadingTorrents::pauseTorrent(QString hash) {
int row = getRowFromHash ( hash ) ;
if ( row = = - 1 )
return ;
src Model- > setData ( src Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
src Model- > setData ( src Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
src Model- > setData ( src Model- > index ( row , NAME ) , QIcon ( QString : : fromUtf8 ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
src Model- > setData ( src Model- > index ( row , SEEDSLEECH ) , QVariant ( QString : : fromUtf8 ( " 0/0 " ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QIcon ( QString : : fromUtf8 ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , SEEDSLEECH ) , QVariant ( QString : : fromUtf8 ( " 0/0 " ) ) ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
//srcModel->setData(src Model->index(row, PROGRESS), QVariant((double)h.progress()));
//DLListModel->setData(DLList Model->index(row, PROGRESS), QVariant((double)h.progress()));
setRowColor ( row , QString : : fromUtf8 ( " red " ) ) ;
}
@ -178,7 +178,7 @@ QString DownloadingTorrents::getHashFromRow(unsigned int row) const {
@@ -178,7 +178,7 @@ QString DownloadingTorrents::getHashFromRow(unsigned int row) const {
// Show torrent properties dialog
void DownloadingTorrents : : showProperties ( const QModelIndex & index ) {
showPropertiesFromHash ( src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ) ;
showPropertiesFromHash ( DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ) ;
}
void DownloadingTorrents : : showPropertiesFromHash ( QString hash ) {
@ -198,7 +198,7 @@ void DownloadingTorrents::deleteTorrent(QString hash) {
@@ -198,7 +198,7 @@ void DownloadingTorrents::deleteTorrent(QString hash) {
qDebug ( " torrent is not in download list, nothing to delete " ) ;
return ;
}
src Model- > removeRow ( row ) ;
DLList Model- > removeRow ( row ) ;
- - nbTorrents ;
emit unfinishedTorrentsNumberChanged ( nbTorrents ) ;
}
@ -209,7 +209,7 @@ void DownloadingTorrents::on_actionSet_download_limit_triggered() {
@@ -209,7 +209,7 @@ void DownloadingTorrents::on_actionSet_download_limit_triggered() {
foreach ( const QModelIndex & index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file hash
hashes < < src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
hashes < < DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
}
}
Q_ASSERT ( hashes . size ( ) > 0 ) ;
@ -222,7 +222,7 @@ void DownloadingTorrents::on_actionSet_upload_limit_triggered() {
@@ -222,7 +222,7 @@ void DownloadingTorrents::on_actionSet_upload_limit_triggered() {
foreach ( const QModelIndex & index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file hash
hashes < < src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
hashes < < DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
}
}
Q_ASSERT ( hashes . size ( ) > 0 ) ;
@ -243,7 +243,7 @@ void DownloadingTorrents::forceRecheck() {
@@ -243,7 +243,7 @@ void DownloadingTorrents::forceRecheck() {
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
foreach ( const QModelIndex & index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
QString hash = src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
QString hash = DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) )
h . force_recheck ( ) ;
@ -262,7 +262,7 @@ void DownloadingTorrents::displayDLListMenu(const QPoint&) {
@@ -262,7 +262,7 @@ void DownloadingTorrents::displayDLListMenu(const QPoint&) {
foreach ( const QModelIndex & index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file name
QString hash = src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
QString hash = DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
// Get handle and pause the torrent
h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) ) continue ;
@ -338,7 +338,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint&){
@@ -338,7 +338,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint&){
// toggle hide/show a column
void DownloadingTorrents : : hideOrShowColumn ( int index ) {
unsigned int nbVisibleColumns = 0 ;
unsigned int nbCols = src Model- > columnCount ( ) ;
unsigned int nbCols = DLList Model- > columnCount ( ) ;
// Count visible columns
for ( unsigned int i = 0 ; i < nbCols ; + + i ) {
if ( ! downloadList - > isColumnHidden ( i ) )
@ -378,7 +378,7 @@ void DownloadingTorrents::hidePriorityColumn(bool hide) {
@@ -378,7 +378,7 @@ void DownloadingTorrents::hidePriorityColumn(bool hide) {
void DownloadingTorrents : : saveHiddenColumns ( ) {
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QStringList ishidden_list ;
short nbColumns = src Model- > columnCount ( ) - 1 ;
short nbColumns = DLList Model- > columnCount ( ) - 1 ;
for ( short i = 0 ; i < nbColumns ; + + i ) {
if ( downloadList - > isColumnHidden ( i ) ) {
@ -398,7 +398,7 @@ bool DownloadingTorrents::loadHiddenColumns() {
@@ -398,7 +398,7 @@ bool DownloadingTorrents::loadHiddenColumns() {
QStringList ishidden_list ;
if ( ! line . isEmpty ( ) ) {
ishidden_list = line . split ( ' ' ) ;
if ( ishidden_list . size ( ) = = src Model- > columnCount ( ) - 1 ) {
if ( ishidden_list . size ( ) = = DLList Model- > columnCount ( ) - 1 ) {
unsigned int listSize = ishidden_list . size ( ) ;
for ( unsigned int i = 0 ; i < listSize ; + + i ) {
downloadList - > header ( ) - > resizeSection ( i , ishidden_list . at ( i ) . toInt ( ) ) ;
@ -406,7 +406,7 @@ bool DownloadingTorrents::loadHiddenColumns() {
@@ -406,7 +406,7 @@ bool DownloadingTorrents::loadHiddenColumns() {
loaded = true ;
}
}
for ( int i = 0 ; i < src Model- > columnCount ( ) - 1 ; i + + ) {
for ( int i = 0 ; i < DLList Model- > columnCount ( ) - 1 ; i + + ) {
if ( loaded & & ishidden_list . at ( i ) = = " 0 " ) {
downloadList - > setColumnHidden ( i , true ) ;
getActionHoSCol ( i ) - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/button_cancel.png " ) ) ) ;
@ -494,7 +494,7 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
@@ -494,7 +494,7 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
foreach ( const QModelIndex & index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file hash
QString hash = src Model- > data ( src Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
QString hash = DLList Model- > data ( DLList Model- > index ( index . row ( ) , HASH ) ) . toString ( ) ;
res < < hash ;
if ( only_one ) break ;
}
@ -507,8 +507,8 @@ void DownloadingTorrents::updateMetadata(QTorrentHandle &h) {
@@ -507,8 +507,8 @@ void DownloadingTorrents::updateMetadata(QTorrentHandle &h) {
int row = getRowFromHash ( hash ) ;
if ( row ! = - 1 ) {
qDebug ( " Updating torrent metadata in download list " ) ;
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( h . name ( ) ) ) ;
src Model- > setData ( src Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( h . name ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
}
}
@ -529,29 +529,29 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
@@ -529,29 +529,29 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
Q_ASSERT ( row ! = - 1 ) ;
// Update Priority
if ( BTSession - > isQueueingEnabled ( ) ) {
src Model- > setData ( src Model- > index ( row , PRIORITY ) , QVariant ( ( int ) BTSession - > getDlTorrentPriority ( hash ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , PRIORITY ) , QVariant ( ( int ) BTSession - > getDlTorrentPriority ( hash ) ) ) ;
if ( h . is_queued ( ) ) {
if ( h . state ( ) = = torrent_status : : checking_files | | h . state ( ) = = torrent_status : : queued_for_checking ) {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/time.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/time.png " ) ) ) , Qt : : DecorationRole ) ;
if ( ! downloadList - > isColumnHidden ( PROGRESS ) ) {
src Model- > setData ( src Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
}
} else {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/queued.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/queued.png " ) ) ) , Qt : : DecorationRole ) ;
if ( ! downloadList - > isColumnHidden ( ETA ) ) {
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
}
}
// Reset speeds and seeds/leech
src Model- > setData ( src Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
src Model- > setData ( src Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
src Model- > setData ( src Model- > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
setRowColor ( row , QString : : fromUtf8 ( " grey " ) ) ;
return added ;
}
}
if ( ! downloadList - > isColumnHidden ( PROGRESS ) )
src Model- > setData ( src Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
// No need to update a paused torrent
if ( h . is_paused ( ) ) return added ;
// Parse download state
@ -559,34 +559,34 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
@@ -559,34 +559,34 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
switch ( h . state ( ) ) {
case torrent_status : : checking_files :
case torrent_status : : queued_for_checking :
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/time.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/time.png " ) ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , QString : : fromUtf8 ( " grey " ) ) ;
break ;
case torrent_status : : downloading :
case torrent_status : : downloading_metadata :
if ( h . download_payload_rate ( ) > 0 ) {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/downloading.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/downloading.png " ) ) ) , Qt : : DecorationRole ) ;
if ( ! downloadList - > isColumnHidden ( ETA ) ) {
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) BTSession - > getETA ( hash ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) BTSession - > getETA ( hash ) ) ) ;
}
setRowColor ( row , QString : : fromUtf8 ( " green " ) ) ;
} else {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/stalled.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/stalled.png " ) ) ) , Qt : : DecorationRole ) ;
if ( ! downloadList - > isColumnHidden ( ETA ) ) {
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
}
setRowColor ( row , QApplication : : palette ( ) . color ( QPalette : : WindowText ) ) ;
}
if ( ! downloadList - > isColumnHidden ( DLSPEED ) ) {
src Model- > setData ( src Model- > index ( row , DLSPEED ) , QVariant ( ( double ) h . download_payload_rate ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , DLSPEED ) , QVariant ( ( double ) h . download_payload_rate ( ) ) ) ;
}
if ( ! downloadList - > isColumnHidden ( UPSPEED ) ) {
src Model- > setData ( src Model- > index ( row , UPSPEED ) , QVariant ( ( double ) h . upload_payload_rate ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , UPSPEED ) , QVariant ( ( double ) h . upload_payload_rate ( ) ) ) ;
}
break ;
default :
if ( ! downloadList - > isColumnHidden ( ETA ) ) {
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
}
}
if ( ! downloadList - > isColumnHidden ( SEEDSLEECH ) ) {
@ -596,10 +596,10 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
@@ -596,10 +596,10 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
tmp . append ( QString ( " / " ) + misc : : toQString ( h . num_peers ( ) - h . num_seeds ( ) , true ) ) ;
if ( h . num_incomplete ( ) > = 0 )
tmp . append ( QString ( " ( " ) + misc : : toQString ( h . num_incomplete ( ) ) + QString ( " ) " ) ) ;
src Model- > setData ( src Model- > index ( row , SEEDSLEECH ) , QVariant ( tmp ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , SEEDSLEECH ) , QVariant ( tmp ) ) ;
}
if ( ! downloadList - > isColumnHidden ( RATIO ) ) {
src Model- > setData ( src Model- > index ( row , RATIO ) , QVariant ( misc : : toQString ( BTSession - > getRealRatio ( hash ) ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , RATIO ) , QVariant ( misc : : toQString ( BTSession - > getRealRatio ( hash ) ) ) ) ;
}
} catch ( invalid_handle e ) { }
return added ;
@ -610,26 +610,26 @@ void DownloadingTorrents::addTorrent(QString hash) {
@@ -610,26 +610,26 @@ void DownloadingTorrents::addTorrent(QString hash) {
int row = getRowFromHash ( hash ) ;
qDebug ( " DL: addTorrent(): %s, row: %d " , ( const char * ) hash . toLocal8Bit ( ) , row ) ;
if ( row ! = - 1 ) return ;
row = src Model- > rowCount ( ) ;
row = DLList Model- > rowCount ( ) ;
// Adding torrent to download list
src Model- > insertRow ( row ) ;
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( h . name ( ) ) ) ;
src Model- > setData ( src Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
src Model- > setData ( src Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
src Model- > setData ( src Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
src Model- > setData ( src Model- > index ( row , SEEDSLEECH ) , QVariant ( QString : : fromUtf8 ( " 0/0 " ) ) ) ;
src Model- > setData ( src Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
src Model- > setData ( src Model- > index ( row , RATIO ) , QVariant ( ( double ) 0. ) ) ;
src Model- > setData ( src Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLList Model- > insertRow ( row ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( h . name ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , SEEDSLEECH ) , QVariant ( QString : : fromUtf8 ( " 0/0 " ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , PROGRESS ) , QVariant ( ( double ) h . progress ( ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , RATIO ) , QVariant ( ( double ) 0. ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
if ( BTSession - > isQueueingEnabled ( ) )
src Model- > setData ( src Model- > index ( row , PRIORITY ) , QVariant ( ( int ) BTSession - > getDlTorrentPriority ( hash ) ) ) ;
src Model- > setData ( src Model- > index ( row , HASH ) , QVariant ( hash ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , PRIORITY ) , QVariant ( ( int ) BTSession - > getDlTorrentPriority ( hash ) ) ) ;
DLList Model- > setData ( DLList Model- > index ( row , HASH ) , QVariant ( hash ) ) ;
// Pause torrent if it is
if ( h . is_paused ( ) ) {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/paused.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/paused.png " ) ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , QString : : fromUtf8 ( " red " ) ) ;
} else {
src Model- > setData ( src Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/stalled.png " ) ) ) , Qt : : DecorationRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/stalled.png " ) ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , QString : : fromUtf8 ( " grey " ) ) ;
}
+ + nbTorrents ;
@ -643,7 +643,7 @@ void DownloadingTorrents::saveColWidthDLList() const{
@@ -643,7 +643,7 @@ void DownloadingTorrents::saveColWidthDLList() const{
QSettings settings ( QString : : fromUtf8 ( " qBittorrent " ) , QString : : fromUtf8 ( " qBittorrent " ) ) ;
QStringList width_list ;
QStringList new_width_list ;
short nbColumns = src Model- > columnCount ( ) - 1 ;
short nbColumns = DLList Model- > columnCount ( ) - 1 ;
QString line = settings . value ( " DownloadListColsWidth " , QString ( ) ) . toString ( ) ;
if ( ! line . isEmpty ( ) ) {
width_list = line . split ( ' ' ) ;
@ -679,7 +679,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
@@ -679,7 +679,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
if ( line . isEmpty ( ) )
return false ;
QStringList width_list = line . split ( QString : : fromUtf8 ( " " ) ) ;
if ( width_list . size ( ) ! = src Model- > columnCount ( ) - 1 ) {
if ( width_list . size ( ) ! = DLList Model- > columnCount ( ) - 1 ) {
qDebug ( " Corrupted values for download list columns sizes " ) ;
return false ;
}
@ -688,7 +688,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
@@ -688,7 +688,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
downloadList - > header ( ) - > resizeSection ( i , width_list . at ( i ) . toInt ( ) ) ;
}
QVariantList visualIndexes = settings . value ( QString : : fromUtf8 ( " DownloadListVisualIndexes " ) , QVariantList ( ) ) . toList ( ) ;
if ( visualIndexes . size ( ) ! = src Model- > columnCount ( ) - 1 ) {
if ( visualIndexes . size ( ) ! = DLList Model- > columnCount ( ) - 1 ) {
qDebug ( " Corrupted values for download list columns sizes " ) ;
return false ;
}
@ -740,24 +740,24 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
@@ -740,24 +740,24 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
int row = getRowFromHash ( hash ) ;
Q_ASSERT ( row ! = - 1 ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
src Model- > setData ( src Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
//srcModel->setData(src Model->index(row, PROGRESS), QVariant((double)h.progress()));
DLList Model- > setData ( DLList Model- > index ( row , SIZE ) , QVariant ( ( qlonglong ) h . actual_size ( ) ) ) ;
//DLListModel->setData(DLList Model->index(row, PROGRESS), QVariant((double)h.progress()));
}
// Set the color of a row in data model
void DownloadingTorrents : : setRowColor ( int row , QColor color ) {
unsigned int nbColumns = src Model- > columnCount ( ) - 1 ;
unsigned int nbColumns = DLList Model- > columnCount ( ) - 1 ;
for ( unsigned int i = 0 ; i < nbColumns ; + + i ) {
src Model- > setData ( src Model- > index ( row , i ) , QVariant ( color ) , Qt : : ForegroundRole ) ;
DLList Model- > setData ( DLList Model- > index ( row , i ) , QVariant ( color ) , Qt : : ForegroundRole ) ;
}
}
// return the row of in data model
// corresponding to the given the hash
int DownloadingTorrents : : getRowFromHash ( QString hash ) const {
unsigned int nbRows = src Model- > rowCount ( ) ;
unsigned int nbRows = DLList Model- > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
if ( src Model- > data ( src Model- > index ( i , HASH ) ) = = hash ) {
if ( DLList Model- > data ( DLList Model- > index ( i , HASH ) ) = = hash ) {
return i ;
}
}