@ -38,17 +38,14 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
actionStart - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/play.png " ) ) ) ;
actionStart - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/play.png " ) ) ) ;
actionPause - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/pause.png " ) ) ) ;
actionPause - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/pause.png " ) ) ) ;
connect ( BTSession , SIGNAL ( addedTorrent ( QTorrentHandle & ) ) , this , SLOT ( torrentAdded ( QTorrentHandle & ) ) ) ;
connect ( BTSession , SIGNAL ( addedTorrent ( QTorrentHandle & ) ) , this , SLOT ( torrentAdded ( QTorrentHandle & ) ) ) ;
finishedListModel = new QStandardItemModel ( 0 , 7 ) ;
finishedListModel = new QStandardItemModel ( 0 , 6 ) ;
finishedListModel - > setHeaderData ( F_NAME , Qt : : Horizontal , tr ( " Name " , " i.e: file name " ) ) ;
finishedListModel - > setHeaderData ( F_NAME , Qt : : Horizontal , tr ( " Name " , " i.e: file name " ) ) ;
finishedListModel - > setHeaderData ( F_SIZE , Qt : : Horizontal , tr ( " Size " , " i.e: file size " ) ) ;
finishedListModel - > setHeaderData ( F_SIZE , Qt : : Horizontal , tr ( " Size " , " i.e: file size " ) ) ;
finishedListModel - > setHeaderData ( F_UPSPEED , Qt : : Horizontal , tr ( " UP Speed " , " i.e: Upload speed " ) ) ;
finishedListModel - > setHeaderData ( F_UPSPEED , Qt : : Horizontal , tr ( " UP Speed " , " i.e: Upload speed " ) ) ;
finishedListModel - > setHeaderData ( F_LEECH , Qt : : Horizontal , tr ( " Leechers " , " i.e: full/partial sources " ) ) ;
finishedListModel - > setHeaderData ( F_LEECH , Qt : : Horizontal , tr ( " Leechers " , " i.e: full/partial sources " ) ) ;
finishedListModel - > setHeaderData ( F_RATIO , Qt : : Horizontal , tr ( " Ratio " ) ) ;
finishedListModel - > setHeaderData ( F_RATIO , Qt : : Horizontal , tr ( " Ratio " ) ) ;
finishedListModel - > setHeaderData ( F_PRIORITY , Qt : : Horizontal , tr ( " Priority " ) ) ;
finishedList - > setModel ( finishedListModel ) ;
finishedList - > setModel ( finishedListModel ) ;
loadHiddenColumns ( ) ;
loadHiddenColumns ( ) ;
// Hide priority column
finishedList - > hideColumn ( F_PRIORITY ) ;
// Hide hash column
// Hide hash column
finishedList - > hideColumn ( F_HASH ) ;
finishedList - > hideColumn ( F_HASH ) ;
// Load last columns width for download list
// Load last columns width for download list
@ -74,8 +71,6 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect ( actionPause , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionPause_triggered ( ) ) ) ;
connect ( actionPause , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionPause_triggered ( ) ) ) ;
connect ( actionStart , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionStart_triggered ( ) ) ) ;
connect ( actionStart , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionStart_triggered ( ) ) ) ;
connect ( actionDelete , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionDelete_triggered ( ) ) ) ;
connect ( actionDelete , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionDelete_triggered ( ) ) ) ;
connect ( actionIncreasePriority , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionIncreasePriority_triggered ( ) ) ) ;
connect ( actionDecreasePriority , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionDecreasePriority_triggered ( ) ) ) ;
connect ( actionPreview_file , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionPreview_file_triggered ( ) ) ) ;
connect ( actionPreview_file , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionPreview_file_triggered ( ) ) ) ;
connect ( actionDelete_Permanently , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionDelete_Permanently_triggered ( ) ) ) ;
connect ( actionDelete_Permanently , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( on_actionDelete_Permanently_triggered ( ) ) ) ;
connect ( actionOpen_destination_folder , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( openDestinationFolder ( ) ) ) ;
connect ( actionOpen_destination_folder , SIGNAL ( triggered ( ) ) , ( GUI * ) parent , SLOT ( openDestinationFolder ( ) ) ) ;
@ -87,7 +82,6 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect ( actionHOSColUpSpeed , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnUpSpeed ( ) ) ) ;
connect ( actionHOSColUpSpeed , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnUpSpeed ( ) ) ) ;
connect ( actionHOSColLeechers , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnLeechers ( ) ) ) ;
connect ( actionHOSColLeechers , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnLeechers ( ) ) ) ;
connect ( actionHOSColRatio , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnRatio ( ) ) ) ;
connect ( actionHOSColRatio , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnRatio ( ) ) ) ;
connect ( actionHOSColPriority , SIGNAL ( triggered ( ) ) , this , SLOT ( hideOrShowColumnPriority ( ) ) ) ;
}
}
FinishedTorrents : : ~ FinishedTorrents ( ) {
FinishedTorrents : : ~ FinishedTorrents ( ) {
@ -103,14 +97,6 @@ void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
emit torrentDoubleClicked ( hash , true ) ;
emit torrentDoubleClicked ( hash , true ) ;
}
}
void FinishedTorrents : : hidePriorityColumn ( bool hide ) {
finishedList - > setColumnHidden ( F_PRIORITY , hide ) ;
if ( hide )
getActionHoSCol ( F_PRIORITY ) - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/button_cancel.png " ) ) ) ;
else
getActionHoSCol ( F_PRIORITY ) - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/button_ok.png " ) ) ) ;
}
void FinishedTorrents : : addTorrent ( QString hash ) {
void FinishedTorrents : : addTorrent ( QString hash ) {
if ( ! BTSession - > isFinished ( hash ) ) {
if ( ! BTSession - > isFinished ( hash ) ) {
BTSession - > setFinishedTorrent ( hash ) ;
BTSession - > setFinishedTorrent ( hash ) ;
@ -126,8 +112,6 @@ void FinishedTorrents::addTorrent(QString hash){
finishedListModel - > setData ( finishedListModel - > index ( row , F_UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_LEECH ) , QVariant ( " 0 " ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_LEECH ) , QVariant ( " 0 " ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_RATIO ) , QVariant ( QString : : fromUtf8 ( misc : : toString ( BTSession - > getRealRatio ( hash ) ) . c_str ( ) ) ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_RATIO ) , QVariant ( QString : : fromUtf8 ( misc : : toString ( BTSession - > getRealRatio ( hash ) ) . c_str ( ) ) ) ) ;
if ( BTSession - > isQueueingEnabled ( ) )
finishedListModel - > setData ( finishedListModel - > index ( row , F_PRIORITY ) , QVariant ( ( int ) BTSession - > getUpTorrentPriority ( hash ) ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_HASH ) , QVariant ( hash ) ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_HASH ) , QVariant ( hash ) ) ;
if ( h . is_paused ( ) ) {
if ( h . is_paused ( ) ) {
finishedListModel - > setData ( finishedListModel - > index ( row , F_NAME ) , QIcon ( " :/Icons/skin/paused.png " ) , Qt : : DecorationRole ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_NAME ) , QIcon ( " :/Icons/skin/paused.png " ) , Qt : : DecorationRole ) ;
@ -271,15 +255,12 @@ void FinishedTorrents::updateFinishedList(){
row = getRowFromHash ( hash ) ;
row = getRowFromHash ( hash ) ;
}
}
Q_ASSERT ( row ! = - 1 ) ;
Q_ASSERT ( row ! = - 1 ) ;
// Update priority
// Update queued torrent
if ( BTSession - > isQueueingEnabled ( ) ) {
if ( BTSession - > isQueueingEnabled ( ) & & BTSession - > isTorrentQueued ( hash ) ) {
finishedListModel - > setData ( finishedListModel - > index ( row , F_PRIORITY ) , QVariant ( ( int ) BTSession - > getUpTorrentPriority ( hash ) ) ) ;
if ( h . is_paused ( ) & & BTSession - > isUploadQueued ( hash ) ) {
finishedListModel - > setData ( finishedListModel - > index ( row , F_NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/queued.png " ) ) ) , Qt : : DecorationRole ) ;
finishedListModel - > setData ( finishedListModel - > index ( row , F_NAME ) , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/queued.png " ) ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , QString : : fromUtf8 ( " grey " ) ) ;
setRowColor ( row , QString : : fromUtf8 ( " grey " ) ) ;
}
}
}
if ( h . is_paused ( ) ) continue ;
if ( h . is_paused ( ) | | h . is_queued ( ) ) continue ;
if ( h . state ( ) = = torrent_status : : downloading | | ( h . state ( ) ! = torrent_status : : checking_files & & h . state ( ) ! = torrent_status : : queued_for_checking & & h . progress ( ) < 1. ) ) {
if ( h . state ( ) = = torrent_status : : downloading | | ( h . state ( ) ! = torrent_status : : checking_files & & h . state ( ) ! = torrent_status : : queued_for_checking & & h . progress ( ) < 1. ) ) {
// What are you doing here? go back to download tab!
// What are you doing here? go back to download tab!
int reponse = QMessageBox : : question ( this , tr ( " Incomplete torrent in seeding list " ) , tr ( " It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted) " ) . arg ( h . name ( ) ) , QMessageBox : : Yes | QMessageBox : : No ) ;
int reponse = QMessageBox : : question ( this , tr ( " Incomplete torrent in seeding list " ) , tr ( " It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted) " ) . arg ( h . name ( ) ) , QMessageBox : : Yes | QMessageBox : : No ) ;
@ -428,11 +409,6 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addAction ( actionOpen_destination_folder ) ;
myFinishedListMenu . addAction ( actionOpen_destination_folder ) ;
myFinishedListMenu . addAction ( actionTorrent_Properties ) ;
myFinishedListMenu . addAction ( actionTorrent_Properties ) ;
if ( BTSession - > isQueueingEnabled ( ) ) {
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addAction ( actionIncreasePriority ) ;
myFinishedListMenu . addAction ( actionDecreasePriority ) ;
}
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addAction ( actionBuy_it ) ;
myFinishedListMenu . addAction ( actionBuy_it ) ;
@ -450,12 +426,7 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
void FinishedTorrents : : displayFinishedHoSMenu ( const QPoint & pos ) {
void FinishedTorrents : : displayFinishedHoSMenu ( const QPoint & pos ) {
QMenu hideshowColumn ( this ) ;
QMenu hideshowColumn ( this ) ;
hideshowColumn . setTitle ( tr ( " Hide or Show Column " ) ) ;
hideshowColumn . setTitle ( tr ( " Hide or Show Column " ) ) ;
int lastCol ;
int lastCol = F_RATIO ;
if ( BTSession - > isQueueingEnabled ( ) ) {
lastCol = F_PRIORITY ;
} else {
lastCol = F_RATIO ;
}
for ( int i = 0 ; i < = lastCol ; i + + ) {
for ( int i = 0 ; i < = lastCol ; i + + ) {
hideshowColumn . addAction ( getActionHoSCol ( i ) ) ;
hideshowColumn . addAction ( getActionHoSCol ( i ) ) ;
}
}
@ -514,10 +485,6 @@ void FinishedTorrents::hideOrShowColumnRatio() {
hideOrShowColumn ( F_RATIO ) ;
hideOrShowColumn ( F_RATIO ) ;
}
}
void FinishedTorrents : : hideOrShowColumnPriority ( ) {
hideOrShowColumn ( F_PRIORITY ) ;
}
// load the previous settings, and hide the columns
// load the previous settings, and hide the columns
bool FinishedTorrents : : loadHiddenColumns ( ) {
bool FinishedTorrents : : loadHiddenColumns ( ) {
bool loaded = false ;
bool loaded = false ;
@ -579,9 +546,6 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
case F_RATIO :
case F_RATIO :
return actionHOSColRatio ;
return actionHOSColRatio ;
break ;
break ;
case F_PRIORITY :
return actionHOSColPriority ;
break ;
default :
default :
return NULL ;
return NULL ;
}
}
@ -600,7 +564,6 @@ void FinishedTorrents::toggleFinishedListSortOrder(int index) {
switch ( index ) {
switch ( index ) {
case F_SIZE :
case F_SIZE :
case F_UPSPEED :
case F_UPSPEED :
case F_PRIORITY :
sortFinishedListFloat ( index , sortOrder ) ;
sortFinishedListFloat ( index , sortOrder ) ;
break ;
break ;
default :
default :
@ -625,7 +588,6 @@ void FinishedTorrents::sortFinishedList(int index, Qt::SortOrder sortOrder){
switch ( index ) {
switch ( index ) {
case F_SIZE :
case F_SIZE :
case F_UPSPEED :
case F_UPSPEED :
case F_PRIORITY :
sortFinishedListFloat ( index , sortOrder ) ;
sortFinishedListFloat ( index , sortOrder ) ;
break ;
break ;
default :
default :