@ -68,7 +68,8 @@
@@ -68,7 +68,8 @@
using namespace libtorrent ;
TransferListWidget : : TransferListWidget ( QWidget * parent , MainWindow * main_window , QBtSession * _BTSession ) :
QTreeView ( parent ) , BTSession ( _BTSession ) , main_window ( main_window ) {
QTreeView ( parent ) , BTSession ( _BTSession ) , main_window ( main_window )
{
setUniformRowHeights ( true ) ;
// Load settings
@ -153,7 +154,8 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
@@ -153,7 +154,8 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
deleteHotkey = new QShortcut ( QKeySequence : : Delete , this , SLOT ( deleteSelectedTorrents ( ) ) , 0 , Qt : : WidgetShortcut ) ;
}
TransferListWidget : : ~ TransferListWidget ( ) {
TransferListWidget : : ~ TransferListWidget ( )
{
qDebug ( ) < < Q_FUNC_INFO < < " ENTER " ;
// Save settings
saveSettings ( ) ;
@ -166,59 +168,65 @@ TransferListWidget::~TransferListWidget() {
@@ -166,59 +168,65 @@ TransferListWidget::~TransferListWidget() {
qDebug ( ) < < Q_FUNC_INFO < < " EXIT " ;
}
TorrentModel * TransferListWidget : : getSourceModel ( ) const {
TorrentModel * TransferListWidget : : getSourceModel ( ) const
{
return listModel ;
}
void TransferListWidget : : previewFile ( QString filePath ) {
void TransferListWidget : : previewFile ( QString filePath )
{
openUrl ( filePath ) ;
}
void TransferListWidget : : setRefreshInterval ( int t ) {
void TransferListWidget : : setRefreshInterval ( int t )
{
qDebug ( " Settings transfer list refresh interval to %dms " , t ) ;
listModel - > setRefreshInterval ( t ) ;
}
int TransferListWidget : : getRowFromHash ( QString hash ) const {
int TransferListWidget : : getRowFromHash ( QString hash ) const
{
return listModel - > torrentRow ( hash ) ;
}
inline QString TransferListWidget : : getHashFromRow ( int row ) const {
inline QString TransferListWidget : : getHashFromRow ( int row ) const
{
return listModel - > torrentHash ( row ) ;
}
inline QModelIndex TransferListWidget : : mapToSource ( const QModelIndex & index ) const {
inline QModelIndex TransferListWidget : : mapToSource ( const QModelIndex & index ) const
{
Q_ASSERT ( index . isValid ( ) ) ;
if ( index . model ( ) = = nameFilterModel )
return nameFilterModel - > mapToSource ( index ) ;
return index ;
}
inline QModelIndex TransferListWidget : : mapFromSource ( const QModelIndex & index ) const {
inline QModelIndex TransferListWidget : : mapFromSource ( const QModelIndex & index ) const
{
Q_ASSERT ( index . isValid ( ) ) ;
Q_ASSERT ( index . model ( ) = = nameFilterModel ) ;
return nameFilterModel - > mapFromSource ( index ) ;
}
void TransferListWidget : : torrentDoubleClicked ( const QModelIndex & index ) {
void TransferListWidget : : torrentDoubleClicked ( const QModelIndex & index )
{
const int row = mapToSource ( index ) . row ( ) ;
const QString hash = getHashFromRow ( row ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) ) return ;
int action ;
if ( h . is_seed ( ) ) {
if ( h . is_seed ( ) )
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentFn ( ) ;
} else {
else
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentDl ( ) ;
}
switch ( action ) {
case TOGGLE_PAUSE :
if ( h . is_paused ( ) ) {
if ( h . is_paused ( ) )
h . resume ( ) ;
} else {
else
h . pause ( ) ;
}
break ;
case OPEN_DEST :
const QString path = h . root_path ( ) ;
@ -226,16 +234,17 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
@@ -226,16 +234,17 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
}
}
QStringList TransferListWidget : : getSelectedTorrentsHashes ( ) const {
QStringList TransferListWidget : : getSelectedTorrentsHashes ( ) const
{
QStringList hashes ;
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
foreach ( const QModelIndex & index , selectedIndexes ) {
foreach ( const QModelIndex & index , selectedIndexes )
hashes < < getHashFromRow ( mapToSource ( index ) . row ( ) ) ;
}
return hashes ;
}
void TransferListWidget : : setSelectedTorrentsLocation ( ) {
void TransferListWidget : : setSelectedTorrentsLocation ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . isEmpty ( ) ) return ;
QString dir ;
@ -254,7 +263,8 @@ void TransferListWidget::setSelectedTorrentsLocation() {
@@ -254,7 +263,8 @@ void TransferListWidget::setSelectedTorrentsLocation() {
if ( ! BTSession - > useTemporaryFolder ( ) | | h . is_seed ( ) ) {
if ( ! savePath . exists ( ) ) savePath . mkpath ( savePath . absolutePath ( ) ) ;
h . move_storage ( savePath . absolutePath ( ) ) ;
} else {
}
else {
TorrentPersistentData : : saveSavePath ( h . hash ( ) , savePath . absolutePath ( ) ) ;
main_window - > getProperties ( ) - > updateSavePath ( h ) ;
}
@ -262,43 +272,44 @@ void TransferListWidget::setSelectedTorrentsLocation() {
@@ -262,43 +272,44 @@ void TransferListWidget::setSelectedTorrentsLocation() {
}
}
void TransferListWidget : : startSelectedTorrents ( ) {
void TransferListWidget : : startSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > resumeTorrent ( hash ) ;
}
}
void TransferListWidget : : startVisibleTorrents ( ) {
void TransferListWidget : : startVisibleTorrents ( )
{
QStringList hashes ;
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > resumeTorrent ( hash ) ;
}
}
void TransferListWidget : : pauseSelectedTorrents ( ) {
void TransferListWidget : : pauseSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > pauseTorrent ( hash ) ;
}
}
void TransferListWidget : : pauseVisibleTorrents ( ) {
void TransferListWidget : : pauseVisibleTorrents ( )
{
QStringList hashes ;
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > pauseTorrent ( hash ) ;
}
}
void TransferListWidget : : deleteSelectedTorrents ( ) {
void TransferListWidget : : deleteSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . empty ( ) ) return ;
@ -307,12 +318,12 @@ void TransferListWidget::deleteSelectedTorrents() {
@@ -307,12 +318,12 @@ void TransferListWidget::deleteSelectedTorrents() {
if ( Preferences : : instance ( ) - > confirmTorrentDeletion ( ) & &
! DeletionConfirmationDlg : : askForDeletionConfirmation ( delete_local_files , hashes . size ( ) , torrent . name ( ) ) )
return ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
}
}
void TransferListWidget : : deleteVisibleTorrents ( ) {
void TransferListWidget : : deleteVisibleTorrents ( )
{
if ( nameFilterModel - > rowCount ( ) < = 0 ) return ;
QTorrentHandle torrent = BTSession - > getTorrentHandle ( getHashFromRow ( 0 ) ) ;
bool delete_local_files = false ;
@ -324,12 +335,12 @@ void TransferListWidget::deleteVisibleTorrents() {
@@ -324,12 +335,12 @@ void TransferListWidget::deleteVisibleTorrents() {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
}
}
void TransferListWidget : : increasePrioSelectedTorrents ( ) {
void TransferListWidget : : increasePrioSelectedTorrents ( )
{
qDebug ( ) < < Q_FUNC_INFO ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
@ -338,9 +349,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
@@ -338,9 +349,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
foreach ( const QString & hash , hashes ) {
try {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_seed ( ) ) {
if ( ! h . is_seed ( ) )
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
}
} catch ( invalid_handle & ) { }
}
// Increase torrents priority (starting with the ones with highest priority)
@ -353,7 +363,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
@@ -353,7 +363,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
}
}
void TransferListWidget : : decreasePrioSelectedTorrents ( ) {
void TransferListWidget : : decreasePrioSelectedTorrents ( )
{
qDebug ( ) < < Q_FUNC_INFO ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
@ -362,9 +373,8 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
@@ -362,9 +373,8 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
foreach ( const QString & hash , hashes ) {
try {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_seed ( ) ) {
if ( ! h . is_seed ( ) )
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
}
} catch ( invalid_handle & ) { }
}
// Decrease torrents priority (starting with the ones with lowest priority)
@ -377,29 +387,30 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
@@ -377,29 +387,30 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
}
}
void TransferListWidget : : topPrioSelectedTorrents ( ) {
void TransferListWidget : : topPrioSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
if ( h . is_valid ( ) & & ! h . is_seed ( ) )
h . queue_position_top ( ) ;
}
}
}
void TransferListWidget : : bottomPrioSelectedTorrents ( ) {
void TransferListWidget : : bottomPrioSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
if ( h . is_valid ( ) & & ! h . is_seed ( ) )
h . queue_position_bottom ( ) ;
}
}
}
void TransferListWidget : : copySelectedMagnetURIs ( ) const {
void TransferListWidget : : copySelectedMagnetURIs ( ) const
{
QStringList magnet_uris ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
@ -410,12 +421,14 @@ void TransferListWidget::copySelectedMagnetURIs() const {
@@ -410,12 +421,14 @@ void TransferListWidget::copySelectedMagnetURIs() const {
qApp - > clipboard ( ) - > setText ( magnet_uris . join ( " \n " ) ) ;
}
void TransferListWidget : : hidePriorityColumn ( bool hide ) {
void TransferListWidget : : hidePriorityColumn ( bool hide )
{
qDebug ( " hidePriorityColumn(%d) " , hide ) ;
setColumnHidden ( TorrentModelItem : : TR_PRIORITY , hide ) ;
}
void TransferListWidget : : openSelectedTorrentsFolder ( ) const {
void TransferListWidget : : openSelectedTorrentsFolder ( ) const
{
QSet < QString > pathsList ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
@ -431,17 +444,18 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
@@ -431,17 +444,18 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
}
}
void TransferListWidget : : previewSelectedTorrents ( ) {
void TransferListWidget : : previewSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
const QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
if ( h . is_valid ( ) & & h . has_metadata ( ) )
new PreviewSelect ( this , h ) ;
}
}
}
void TransferListWidget : : setDlLimitSelectedTorrents ( ) {
void TransferListWidget : : setDlLimitSelectedTorrents ( )
{
QList < QTorrentHandle > selected_torrents ;
bool first = true ;
bool all_same_limit = true ;
@ -451,14 +465,13 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
@@ -451,14 +465,13 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
selected_torrents < < h ;
// Determine current limit for selected torrents
if ( first ) {
if ( first )
first = false ;
} else {
else
if ( all_same_limit & & h . download_limit ( ) ! = selected_torrents . first ( ) . download_limit ( ) )
all_same_limit = false ;
}
}
}
if ( selected_torrents . empty ( ) ) return ;
bool ok = false ;
@ -474,7 +487,8 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
@@ -474,7 +487,8 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
}
}
void TransferListWidget : : setUpLimitSelectedTorrents ( ) {
void TransferListWidget : : setUpLimitSelectedTorrents ( )
{
QList < QTorrentHandle > selected_torrents ;
bool first = true ;
bool all_same_limit = true ;
@ -484,14 +498,13 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
@@ -484,14 +498,13 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
if ( h . is_valid ( ) ) {
selected_torrents < < h ;
// Determine current limit for selected torrents
if ( first ) {
if ( first )
first = false ;
} else {
else
if ( all_same_limit & & h . upload_limit ( ) ! = selected_torrents . first ( ) . upload_limit ( ) )
all_same_limit = false ;
}
}
}
if ( selected_torrents . empty ( ) ) return ;
bool ok = false ;
@ -507,7 +520,8 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
@@ -507,7 +520,8 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
}
}
void TransferListWidget : : setMaxRatioSelectedTorrents ( ) {
void TransferListWidget : : setMaxRatioSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . isEmpty ( ) )
return ;
@ -515,7 +529,8 @@ void TransferListWidget::setMaxRatioSelectedTorrents() {
@@ -515,7 +529,8 @@ void TransferListWidget::setMaxRatioSelectedTorrents() {
qreal currentMaxRatio ;
if ( hashes . count ( ) = = 1 ) {
currentMaxRatio = BTSession - > getMaxRatioPerTorrent ( hashes . first ( ) , & useGlobalValue ) ;
} else {
}
else {
useGlobalValue = true ;
currentMaxRatio = BTSession - > getGlobalMaxRatio ( ) ;
}
@ -530,18 +545,19 @@ void TransferListWidget::setMaxRatioSelectedTorrents() {
@@ -530,18 +545,19 @@ void TransferListWidget::setMaxRatioSelectedTorrents() {
}
}
void TransferListWidget : : recheckSelectedTorrents ( ) {
void TransferListWidget : : recheckSelectedTorrents ( )
{
QMessageBox : : StandardButton ret = QMessageBox : : question ( this , tr ( " Recheck confirmation " ) , tr ( " Are you sure you want to recheck the selected torrent(s)? " ) , QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : Yes ) ;
if ( ret ! = QMessageBox : : Yes )
return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > recheckTorrent ( hash ) ;
}
}
// hide/show columns menu
void TransferListWidget : : displayDLHoSMenu ( const QPoint & ) {
void TransferListWidget : : displayDLHoSMenu ( const QPoint & )
{
QMenu hideshowColumn ( this ) ;
hideshowColumn . setTitle ( tr ( " Column visibility " ) ) ;
QList < QAction * > actions ;
@ -579,40 +595,36 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
@@ -579,40 +595,36 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
}
}
void TransferListWidget : : toggleSelectedTorrentsSuperSeeding ( ) const {
void TransferListWidget : : toggleSelectedTorrentsSuperSeeding ( ) const
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
if ( h . is_valid ( ) & & h . has_metadata ( ) )
h . super_seeding ( ! h . status ( 0 ) . super_seeding ) ;
}
}
}
void TransferListWidget : : toggleSelectedTorrentsSequentialDownload ( ) const {
void TransferListWidget : : toggleSelectedTorrentsSequentialDownload ( ) const
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
bool was_sequential = h . is_sequential_download ( ) ;
h . set_sequential_download ( ! was_sequential ) ;
if ( ! was_sequential )
h . prioritize_first_last_piece ( true ) ;
}
h . toggleSequentialDownload ( ) ;
}
}
void TransferListWidget : : toggleSelectedFirstLastPiecePrio ( ) const {
void TransferListWidget : : toggleSelectedFirstLastPiecePrio ( ) const
{
QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
h . prioritize_first_last_piece ( ! h . first_last_piece_first ( ) ) ;
}
h . toggleFirstLastPiecePrio ( ) ;
}
}
void TransferListWidget : : askNewLabelForSelection ( ) {
void TransferListWidget : : askNewLabelForSelection ( )
{
// Ask for label
bool ok ;
bool invalid ;
@ -622,7 +634,8 @@ void TransferListWidget::askNewLabelForSelection() {
@@ -622,7 +634,8 @@ void TransferListWidget::askNewLabelForSelection() {
if ( ok & & ! label . isEmpty ( ) ) {
if ( fsutils : : isValidFileSystemName ( label ) ) {
setSelectionLabel ( label ) ;
} else {
}
else {
QMessageBox : : warning ( this , tr ( " Invalid label name " ) , tr ( " Please don't use any special characters in the label name. " ) ) ;
invalid = true ;
}
@ -630,7 +643,8 @@ void TransferListWidget::askNewLabelForSelection() {
@@ -630,7 +643,8 @@ void TransferListWidget::askNewLabelForSelection() {
} while ( invalid ) ;
}
bool TransferListWidget : : openUrl ( const QString & _path ) const {
bool TransferListWidget : : openUrl ( const QString & _path ) const
{
const QString path = fsutils : : fromNativePath ( _path ) ;
// Hack to access samba shares with QDesktopServices::openUrl
if ( path . startsWith ( " // " ) )
@ -639,7 +653,8 @@ bool TransferListWidget::openUrl(const QString &_path) const {
@@ -639,7 +653,8 @@ bool TransferListWidget::openUrl(const QString &_path) const {
return QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( path ) ) ;
}
void TransferListWidget : : renameSelectedTorrent ( ) {
void TransferListWidget : : renameSelectedTorrent ( )
{
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
if ( selectedIndexes . size ( ) ! = 1 ) return ;
if ( ! selectedIndexes . first ( ) . isValid ( ) ) return ;
@ -657,7 +672,8 @@ void TransferListWidget::renameSelectedTorrent() {
@@ -657,7 +672,8 @@ void TransferListWidget::renameSelectedTorrent() {
}
}
void TransferListWidget : : setSelectionLabel ( QString label ) {
void TransferListWidget : : setSelectionLabel ( QString label )
{
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
Q_ASSERT ( ! hash . isEmpty ( ) ) ;
@ -670,7 +686,8 @@ void TransferListWidget::setSelectionLabel(QString label) {
@@ -670,7 +686,8 @@ void TransferListWidget::setSelectionLabel(QString label) {
}
}
void TransferListWidget : : removeLabelFromRows ( QString label ) {
void TransferListWidget : : removeLabelFromRows ( QString label )
{
for ( int i = 0 ; i < listModel - > rowCount ( ) ; + + i ) {
if ( listModel - > data ( listModel - > index ( i , TorrentModelItem : : TR_LABEL ) ) = = label ) {
const QString hash = getHashFromRow ( i ) ;
@ -682,7 +699,8 @@ void TransferListWidget::removeLabelFromRows(QString label) {
@@ -682,7 +699,8 @@ void TransferListWidget::removeLabelFromRows(QString label) {
}
}
void TransferListWidget : : displayListMenu ( const QPoint & ) {
void TransferListWidget : : displayListMenu ( const QPoint & )
{
QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
if ( selectedIndexes . size ( ) = = 0 )
return ;
@ -754,25 +772,23 @@ void TransferListWidget::displayListMenu(const QPoint&) {
@@ -754,25 +772,23 @@ void TransferListWidget::displayListMenu(const QPoint&) {
if ( first ) {
sequential_download_mode = h . is_sequential_download ( ) ;
prioritize_first_last = h . first_last_piece_first ( ) ;
} else {
if ( sequential_download_mode ! = h . is_sequential_download ( ) ) {
all_same_sequential_download_mode = false ;
}
if ( prioritize_first_last ! = h . first_last_piece_first ( ) ) {
else {
if ( sequential_download_mode ! = h . is_sequential_download ( ) )
all_same_sequential_download_mode = false ;
if ( prioritize_first_last ! = h . first_last_piece_first ( ) )
all_same_prio_firstlast = false ;
}
}
}
}
else {
if ( ! one_not_seed & & all_same_super_seeding & & h . has_metadata ( ) ) {
if ( first ) {
super_seeding_mode = h . status ( 0 ) . super_seeding ;
} else {
if ( super_seeding_mode ! = h . status ( 0 ) . super_seeding ) {
all_same_super_seeding = false ;
}
}
else if ( super_seeding_mode ! = h . status ( 0 ) . super_seeding )
all_same_super_seeding = false ;
}
}
if ( h . is_paused ( ) ) {
@ -780,15 +796,15 @@ void TransferListWidget::displayListMenu(const QPoint&) {
@@ -780,15 +796,15 @@ void TransferListWidget::displayListMenu(const QPoint&) {
listMenu . addAction ( & actionStart ) ;
has_start = true ;
}
} else {
}
else {
if ( ! has_pause ) {
listMenu . addAction ( & actionPause ) ;
has_pause = true ;
}
}
if ( h . has_metadata ( ) & & BTSession - > isFilePreviewPossible ( hash ) & & ! has_preview ) {
if ( h . has_metadata ( ) & & BTSession - > isFilePreviewPossible ( hash ) & & ! has_preview )
has_preview = true ;
}
first = false ;
if ( has_pause & & has_start & & has_preview & & one_not_seed ) break ;
}
@ -806,9 +822,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
@@ -806,9 +822,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " list-add " ) , tr ( " New... " , " New label... " ) ) ;
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " edit-clear " ) , tr ( " Reset " , " Reset label " ) ) ;
labelMenu - > addSeparator ( ) ;
foreach ( const QString & label , customLabels ) {
foreach ( const QString & label , customLabels )
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) , label ) ;
}
listMenu . addSeparator ( ) ;
if ( one_not_seed )
listMenu . addAction ( & actionSet_download_limit ) ;
@ -864,7 +879,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
@@ -864,7 +879,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
if ( i = = 0 ) {
// New Label
askNewLabelForSelection ( ) ;
} else {
}
else {
QString label = " " ;
if ( i > 1 )
label = customLabels . at ( i - 2 ) ;
@ -875,7 +891,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
@@ -875,7 +891,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
}
}
void TransferListWidget : : currentChanged ( const QModelIndex & current , const QModelIndex & ) {
void TransferListWidget : : currentChanged ( const QModelIndex & current , const QModelIndex & )
{
qDebug ( " CURRENT CHANGED " ) ;
QTorrentHandle h ;
if ( current . isValid ( ) ) {
@ -887,20 +904,24 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel
@@ -887,20 +904,24 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel
emit currentTorrentChanged ( h ) ;
}
void TransferListWidget : : applyLabelFilterAll ( ) {
void TransferListWidget : : applyLabelFilterAll ( )
{
nameFilterModel - > disableLabelFilter ( ) ;
}
void TransferListWidget : : applyLabelFilter ( QString label ) {
void TransferListWidget : : applyLabelFilter ( QString label )
{
qDebug ( " Applying Label filter: %s " , qPrintable ( label ) ) ;
nameFilterModel - > setLabelFilter ( label ) ;
}
void TransferListWidget : : applyNameFilter ( const QString & name ) {
void TransferListWidget : : applyNameFilter ( const QString & name )
{
nameFilterModel - > setFilterRegExp ( QRegExp ( QRegExp : : escape ( name ) , Qt : : CaseInsensitive ) ) ;
}
void TransferListWidget : : applyStatusFilter ( int f ) {
void TransferListWidget : : applyStatusFilter ( int f )
{
nameFilterModel - > setStatusFilter ( ( TorrentFilter : : TorrentFilter ) f ) ;
// Select first item if nothing is selected
if ( selectionModel ( ) - > selectedRows ( 0 ) . empty ( ) & & nameFilterModel - > rowCount ( ) > 0 ) {
@ -917,9 +938,8 @@ void TransferListWidget::saveSettings()
@@ -917,9 +938,8 @@ void TransferListWidget::saveSettings()
bool TransferListWidget : : loadSettings ( )
{
bool ok = header ( ) - > restoreState ( Preferences : : instance ( ) - > getTransHeaderState ( ) ) ;
if ( ! ok ) {
if ( ! ok )
header ( ) - > resizeSection ( 0 , 200 ) ; // Default
}
return ok ;
}