@ -68,7 +68,8 @@
using namespace libtorrent ;
using namespace libtorrent ;
TransferListWidget : : TransferListWidget ( QWidget * parent , MainWindow * main_window , QBtSession * _BTSession ) :
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 ) ;
setUniformRowHeights ( true ) ;
// Load settings
// Load settings
@ -125,7 +126,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
//Ensure that at least one column is visible at all times
//Ensure that at least one column is visible at all times
bool atLeastOne = false ;
bool atLeastOne = false ;
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + ) {
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + ) {
if ( ! isColumnHidden ( i ) ) {
if ( ! isColumnHidden ( i ) ) {
atLeastOne = true ;
atLeastOne = true ;
break ;
break ;
@ -137,7 +138,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
//When adding/removing columns between versions some may
//When adding/removing columns between versions some may
//end up being size 0 when the new version is launched with
//end up being size 0 when the new version is launched with
//a conf file from the previous version.
//a conf file from the previous version.
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + )
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + )
if ( ! columnWidth ( i ) )
if ( ! columnWidth ( i ) )
resizeColumnToContents ( i ) ;
resizeColumnToContents ( i ) ;
@ -145,15 +146,16 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
// Listen for list events
// Listen for list events
connect ( this , SIGNAL ( doubleClicked ( QModelIndex ) ) , this , SLOT ( torrentDoubleClicked ( QModelIndex ) ) ) ;
connect ( this , SIGNAL ( doubleClicked ( QModelIndex ) ) , this , SLOT ( torrentDoubleClicked ( QModelIndex ) ) ) ;
connect ( this , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayListMenu ( const QPoint & ) ) ) ;
connect ( this , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayListMenu ( const QPoint & ) ) ) ;
header ( ) - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
header ( ) - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
connect ( header ( ) , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayDLHoSMenu ( const QPoint & ) ) ) ;
connect ( header ( ) , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayDLHoSMenu ( const QPoint & ) ) ) ;
editHotkey = new QShortcut ( QKeySequence ( " F2 " ) , this , SLOT ( renameSelectedTorrent ( ) ) , 0 , Qt : : WidgetShortcut ) ;
editHotkey = new QShortcut ( QKeySequence ( " F2 " ) , this , SLOT ( renameSelectedTorrent ( ) ) , 0 , Qt : : WidgetShortcut ) ;
deleteHotkey = new QShortcut ( QKeySequence : : Delete , this , SLOT ( deleteSelectedTorrents ( ) ) , 0 , Qt : : WidgetShortcut ) ;
deleteHotkey = new QShortcut ( QKeySequence : : Delete , this , SLOT ( deleteSelectedTorrents ( ) ) , 0 , Qt : : WidgetShortcut ) ;
}
}
TransferListWidget : : ~ TransferListWidget ( ) {
TransferListWidget : : ~ TransferListWidget ( )
{
qDebug ( ) < < Q_FUNC_INFO < < " ENTER " ;
qDebug ( ) < < Q_FUNC_INFO < < " ENTER " ;
// Save settings
// Save settings
saveSettings ( ) ;
saveSettings ( ) ;
@ -166,59 +168,65 @@ TransferListWidget::~TransferListWidget() {
qDebug ( ) < < Q_FUNC_INFO < < " EXIT " ;
qDebug ( ) < < Q_FUNC_INFO < < " EXIT " ;
}
}
TorrentModel * TransferListWidget : : getSourceModel ( ) const {
TorrentModel * TransferListWidget : : getSourceModel ( ) const
{
return listModel ;
return listModel ;
}
}
void TransferListWidget : : previewFile ( QString filePath ) {
void TransferListWidget : : previewFile ( QString filePath )
{
openUrl ( filePath ) ;
openUrl ( filePath ) ;
}
}
void TransferListWidget : : setRefreshInterval ( int t ) {
void TransferListWidget : : setRefreshInterval ( int t )
{
qDebug ( " Settings transfer list refresh interval to %dms " , t ) ;
qDebug ( " Settings transfer list refresh interval to %dms " , t ) ;
listModel - > setRefreshInterval ( t ) ;
listModel - > setRefreshInterval ( t ) ;
}
}
int TransferListWidget : : getRowFromHash ( QString hash ) const {
int TransferListWidget : : getRowFromHash ( QString hash ) const
{
return listModel - > torrentRow ( hash ) ;
return listModel - > torrentRow ( hash ) ;
}
}
inline QString TransferListWidget : : getHashFromRow ( int row ) const {
inline QString TransferListWidget : : getHashFromRow ( int row ) const
{
return listModel - > torrentHash ( row ) ;
return listModel - > torrentHash ( row ) ;
}
}
inline QModelIndex TransferListWidget : : mapToSource ( const QModelIndex & index ) const {
inline QModelIndex TransferListWidget : : mapToSource ( const QModelIndex & index ) const
{
Q_ASSERT ( index . isValid ( ) ) ;
Q_ASSERT ( index . isValid ( ) ) ;
if ( index . model ( ) = = nameFilterModel )
if ( index . model ( ) = = nameFilterModel )
return nameFilterModel - > mapToSource ( index ) ;
return nameFilterModel - > mapToSource ( index ) ;
return 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 . isValid ( ) ) ;
Q_ASSERT ( index . model ( ) = = nameFilterModel ) ;
Q_ASSERT ( index . model ( ) = = nameFilterModel ) ;
return nameFilterModel - > mapFromSource ( index ) ;
return nameFilterModel - > mapFromSource ( index ) ;
}
}
void TransferListWidget : : torrentDoubleClicked ( const QModelIndex & index ) {
void TransferListWidget : : torrentDoubleClicked ( const QModelIndex & index )
{
const int row = mapToSource ( index ) . row ( ) ;
const int row = mapToSource ( index ) . row ( ) ;
const QString hash = getHashFromRow ( row ) ;
const QString hash = getHashFromRow ( row ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) ) return ;
if ( ! h . is_valid ( ) ) return ;
int action ;
int action ;
if ( h . is_seed ( ) ) {
if ( h . is_seed ( ) )
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentFn ( ) ;
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentFn ( ) ;
} else {
else
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentDl ( ) ;
action = Preferences : : instance ( ) - > getActionOnDblClOnTorrentDl ( ) ;
}
switch ( action ) {
switch ( action ) {
case TOGGLE_PAUSE :
case TOGGLE_PAUSE :
if ( h . is_paused ( ) ) {
if ( h . is_paused ( ) )
h . resume ( ) ;
h . resume ( ) ;
} else {
else
h . pause ( ) ;
h . pause ( ) ;
}
break ;
break ;
case OPEN_DEST :
case OPEN_DEST :
const QString path = h . root_path ( ) ;
const QString path = h . root_path ( ) ;
@ -226,23 +234,24 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
}
}
}
}
QStringList TransferListWidget : : getSelectedTorrentsHashes ( ) const {
QStringList TransferListWidget : : getSelectedTorrentsHashes ( ) const
{
QStringList hashes ;
QStringList hashes ;
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
foreach ( const QModelIndex & index , selectedIndexes ) {
foreach ( const QModelIndex & index , selectedIndexes )
hashes < < getHashFromRow ( mapToSource ( index ) . row ( ) ) ;
hashes < < getHashFromRow ( mapToSource ( index ) . row ( ) ) ;
}
return hashes ;
return hashes ;
}
}
void TransferListWidget : : setSelectedTorrentsLocation ( ) {
void TransferListWidget : : setSelectedTorrentsLocation ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . isEmpty ( ) ) return ;
if ( hashes . isEmpty ( ) ) return ;
QString dir ;
QString dir ;
const QDir saveDir ( TorrentPersistentData : : getSavePath ( hashes . first ( ) ) ) ;
const QDir saveDir ( TorrentPersistentData : : getSavePath ( hashes . first ( ) ) ) ;
qDebug ( " Old save path is %s " , qPrintable ( saveDir . absolutePath ( ) ) ) ;
qDebug ( " Old save path is %s " , qPrintable ( saveDir . absolutePath ( ) ) ) ;
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose save path " ) , saveDir . absolutePath ( ) ,
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose save path " ) , saveDir . absolutePath ( ) ,
QFileDialog : : DontConfirmOverwrite | QFileDialog : : ShowDirsOnly | QFileDialog : : HideNameFilterDetails ) ;
QFileDialog : : DontConfirmOverwrite | QFileDialog : : ShowDirsOnly | QFileDialog : : HideNameFilterDetails ) ;
if ( ! dir . isNull ( ) ) {
if ( ! dir . isNull ( ) ) {
qDebug ( " New path is %s " , qPrintable ( dir ) ) ;
qDebug ( " New path is %s " , qPrintable ( dir ) ) ;
// Check if savePath exists
// Check if savePath exists
@ -254,7 +263,8 @@ void TransferListWidget::setSelectedTorrentsLocation() {
if ( ! BTSession - > useTemporaryFolder ( ) | | h . is_seed ( ) ) {
if ( ! BTSession - > useTemporaryFolder ( ) | | h . is_seed ( ) ) {
if ( ! savePath . exists ( ) ) savePath . mkpath ( savePath . absolutePath ( ) ) ;
if ( ! savePath . exists ( ) ) savePath . mkpath ( savePath . absolutePath ( ) ) ;
h . move_storage ( savePath . absolutePath ( ) ) ;
h . move_storage ( savePath . absolutePath ( ) ) ;
} else {
}
else {
TorrentPersistentData : : saveSavePath ( h . hash ( ) , savePath . absolutePath ( ) ) ;
TorrentPersistentData : : saveSavePath ( h . hash ( ) , savePath . absolutePath ( ) ) ;
main_window - > getProperties ( ) - > updateSavePath ( h ) ;
main_window - > getProperties ( ) - > updateSavePath ( h ) ;
}
}
@ -262,43 +272,44 @@ void TransferListWidget::setSelectedTorrentsLocation() {
}
}
}
}
void TransferListWidget : : startSelectedTorrents ( ) {
void TransferListWidget : : startSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > resumeTorrent ( hash ) ;
BTSession - > resumeTorrent ( hash ) ;
}
}
}
void TransferListWidget : : startVisibleTorrents ( ) {
void TransferListWidget : : startVisibleTorrents ( )
{
QStringList hashes ;
QStringList hashes ;
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
hashes < < getHashFromRow ( row ) ;
}
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > resumeTorrent ( hash ) ;
BTSession - > resumeTorrent ( hash ) ;
}
}
}
void TransferListWidget : : pauseSelectedTorrents ( ) {
void TransferListWidget : : pauseSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > pauseTorrent ( hash ) ;
BTSession - > pauseTorrent ( hash ) ;
}
}
}
void TransferListWidget : : pauseVisibleTorrents ( ) {
void TransferListWidget : : pauseVisibleTorrents ( )
{
QStringList hashes ;
QStringList hashes ;
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
hashes < < getHashFromRow ( row ) ;
}
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > pauseTorrent ( hash ) ;
BTSession - > pauseTorrent ( hash ) ;
}
}
}
void TransferListWidget : : deleteSelectedTorrents ( ) {
void TransferListWidget : : deleteSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . empty ( ) ) return ;
if ( hashes . empty ( ) ) return ;
@ -307,12 +318,12 @@ void TransferListWidget::deleteSelectedTorrents() {
if ( Preferences : : instance ( ) - > confirmTorrentDeletion ( ) & &
if ( Preferences : : instance ( ) - > confirmTorrentDeletion ( ) & &
! DeletionConfirmationDlg : : askForDeletionConfirmation ( delete_local_files , hashes . size ( ) , torrent . name ( ) ) )
! DeletionConfirmationDlg : : askForDeletionConfirmation ( delete_local_files , hashes . size ( ) , torrent . name ( ) ) )
return ;
return ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
}
}
}
void TransferListWidget : : deleteVisibleTorrents ( ) {
void TransferListWidget : : deleteVisibleTorrents ( )
{
if ( nameFilterModel - > rowCount ( ) < = 0 ) return ;
if ( nameFilterModel - > rowCount ( ) < = 0 ) return ;
QTorrentHandle torrent = BTSession - > getTorrentHandle ( getHashFromRow ( 0 ) ) ;
QTorrentHandle torrent = BTSession - > getTorrentHandle ( getHashFromRow ( 0 ) ) ;
bool delete_local_files = false ;
bool delete_local_files = false ;
@ -320,16 +331,16 @@ void TransferListWidget::deleteVisibleTorrents() {
! DeletionConfirmationDlg : : askForDeletionConfirmation ( delete_local_files , nameFilterModel - > rowCount ( ) , torrent . name ( ) ) )
! DeletionConfirmationDlg : : askForDeletionConfirmation ( delete_local_files , nameFilterModel - > rowCount ( ) , torrent . name ( ) ) )
return ;
return ;
QStringList hashes ;
QStringList hashes ;
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
for ( int i = 0 ; i < nameFilterModel - > rowCount ( ) ; + + i ) {
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
const int row = mapToSource ( nameFilterModel - > index ( i , 0 ) ) . row ( ) ;
hashes < < getHashFromRow ( row ) ;
hashes < < getHashFromRow ( row ) ;
}
}
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
BTSession - > deleteTorrent ( hash , delete_local_files ) ;
}
}
}
void TransferListWidget : : increasePrioSelectedTorrents ( ) {
void TransferListWidget : : increasePrioSelectedTorrents ( )
{
qDebug ( ) < < Q_FUNC_INFO ;
qDebug ( ) < < Q_FUNC_INFO ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
@ -338,9 +349,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
try {
try {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_seed ( ) ) {
if ( ! h . is_seed ( ) )
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
}
} catch ( invalid_handle & ) { }
} catch ( invalid_handle & ) { }
}
}
// Increase torrents priority (starting with the ones with highest priority)
// Increase torrents priority (starting with the ones with highest priority)
@ -353,7 +363,8 @@ void TransferListWidget::increasePrioSelectedTorrents() {
}
}
}
}
void TransferListWidget : : decreasePrioSelectedTorrents ( ) {
void TransferListWidget : : decreasePrioSelectedTorrents ( )
{
qDebug ( ) < < Q_FUNC_INFO ;
qDebug ( ) < < Q_FUNC_INFO ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
@ -362,9 +373,8 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
try {
try {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( ! h . is_seed ( ) ) {
if ( ! h . is_seed ( ) )
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
torrent_queue . push ( qMakePair ( h . queue_position ( ) , h ) ) ;
}
} catch ( invalid_handle & ) { }
} catch ( invalid_handle & ) { }
}
}
// Decrease torrents priority (starting with the ones with lowest priority)
// Decrease torrents priority (starting with the ones with lowest priority)
@ -377,29 +387,30 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
}
}
}
}
void TransferListWidget : : topPrioSelectedTorrents ( ) {
void TransferListWidget : : topPrioSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
if ( h . is_valid ( ) & & ! h . is_seed ( ) )
h . queue_position_top ( ) ;
h . queue_position_top ( ) ;
}
}
}
}
}
void TransferListWidget : : bottomPrioSelectedTorrents ( ) {
void TransferListWidget : : bottomPrioSelectedTorrents ( )
{
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
if ( main_window - > getCurrentTabWidget ( ) ! = this ) return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
if ( h . is_valid ( ) & & ! h . is_seed ( ) )
h . queue_position_bottom ( ) ;
h . queue_position_bottom ( ) ;
}
}
}
}
}
void TransferListWidget : : copySelectedMagnetURIs ( ) const {
void TransferListWidget : : copySelectedMagnetURIs ( ) const
{
QStringList magnet_uris ;
QStringList magnet_uris ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
@ -410,12 +421,14 @@ void TransferListWidget::copySelectedMagnetURIs() const {
qApp - > clipboard ( ) - > setText ( magnet_uris . join ( " \n " ) ) ;
qApp - > clipboard ( ) - > setText ( magnet_uris . join ( " \n " ) ) ;
}
}
void TransferListWidget : : hidePriorityColumn ( bool hide ) {
void TransferListWidget : : hidePriorityColumn ( bool hide )
{
qDebug ( " hidePriorityColumn(%d) " , hide ) ;
qDebug ( " hidePriorityColumn(%d) " , hide ) ;
setColumnHidden ( TorrentModelItem : : TR_PRIORITY , hide ) ;
setColumnHidden ( TorrentModelItem : : TR_PRIORITY , hide ) ;
}
}
void TransferListWidget : : openSelectedTorrentsFolder ( ) const {
void TransferListWidget : : openSelectedTorrentsFolder ( ) const
{
QSet < QString > pathsList ;
QSet < QString > pathsList ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
@ -431,17 +444,18 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
}
}
}
}
void TransferListWidget : : previewSelectedTorrents ( ) {
void TransferListWidget : : previewSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
const QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
const QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
if ( h . is_valid ( ) & & h . has_metadata ( ) )
new PreviewSelect ( this , h ) ;
new PreviewSelect ( this , h ) ;
}
}
}
}
}
void TransferListWidget : : setDlLimitSelectedTorrents ( ) {
void TransferListWidget : : setDlLimitSelectedTorrents ( )
{
QList < QTorrentHandle > selected_torrents ;
QList < QTorrentHandle > selected_torrents ;
bool first = true ;
bool first = true ;
bool all_same_limit = true ;
bool all_same_limit = true ;
@ -451,30 +465,30 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
if ( h . is_valid ( ) & & ! h . is_seed ( ) ) {
selected_torrents < < h ;
selected_torrents < < h ;
// Determine current limit for selected torrents
// Determine current limit for selected torrents
if ( first ) {
if ( first )
first = false ;
first = false ;
} else {
else
if ( all_same_limit & & h . download_limit ( ) ! = selected_torrents . first ( ) . download_limit ( ) )
if ( all_same_limit & & h . download_limit ( ) ! = selected_torrents . first ( ) . download_limit ( ) )
all_same_limit = false ;
all_same_limit = false ;
}
}
}
}
}
if ( selected_torrents . empty ( ) ) return ;
if ( selected_torrents . empty ( ) ) return ;
bool ok = false ;
bool ok = false ;
int default_limit = - 1 ;
int default_limit = - 1 ;
if ( all_same_limit )
if ( all_same_limit )
default_limit = selected_torrents . first ( ) . download_limit ( ) ;
default_limit = selected_torrents . first ( ) . download_limit ( ) ;
const long new_limit = SpeedLimitDialog : : askSpeedLimit ( & ok , tr ( " Torrent Download Speed Limiting " ) , default_limit , Preferences : : instance ( ) - > getGlobalDownloadLimit ( ) * 1024. ) ;
const long new_limit = SpeedLimitDialog : : askSpeedLimit ( & ok , tr ( " Torrent Download Speed Limiting " ) , default_limit , Preferences : : instance ( ) - > getGlobalDownloadLimit ( ) * 1024. ) ;
if ( ok ) {
if ( ok ) {
foreach ( const QTorrentHandle & h , selected_torrents ) {
foreach ( const QTorrentHandle & h , selected_torrents ) {
qDebug ( " Applying download speed limit of %ld Kb/s to torrent %s " , ( long ) ( new_limit / 1024. ) , qPrintable ( h . hash ( ) ) ) ;
qDebug ( " Applying download speed limit of %ld Kb/s to torrent %s " , ( long ) ( new_limit / 1024. ) , qPrintable ( h . hash ( ) ) ) ;
BTSession - > setDownloadLimit ( h . hash ( ) , new_limit ) ;
BTSession - > setDownloadLimit ( h . hash ( ) , new_limit ) ;
}
}
}
}
}
}
void TransferListWidget : : setUpLimitSelectedTorrents ( ) {
void TransferListWidget : : setUpLimitSelectedTorrents ( )
{
QList < QTorrentHandle > selected_torrents ;
QList < QTorrentHandle > selected_torrents ;
bool first = true ;
bool first = true ;
bool all_same_limit = true ;
bool all_same_limit = true ;
@ -484,30 +498,30 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
if ( h . is_valid ( ) ) {
if ( h . is_valid ( ) ) {
selected_torrents < < h ;
selected_torrents < < h ;
// Determine current limit for selected torrents
// Determine current limit for selected torrents
if ( first ) {
if ( first )
first = false ;
first = false ;
} else {
else
if ( all_same_limit & & h . upload_limit ( ) ! = selected_torrents . first ( ) . upload_limit ( ) )
if ( all_same_limit & & h . upload_limit ( ) ! = selected_torrents . first ( ) . upload_limit ( ) )
all_same_limit = false ;
all_same_limit = false ;
}
}
}
}
}
if ( selected_torrents . empty ( ) ) return ;
if ( selected_torrents . empty ( ) ) return ;
bool ok = false ;
bool ok = false ;
int default_limit = - 1 ;
int default_limit = - 1 ;
if ( all_same_limit )
if ( all_same_limit )
default_limit = selected_torrents . first ( ) . upload_limit ( ) ;
default_limit = selected_torrents . first ( ) . upload_limit ( ) ;
const long new_limit = SpeedLimitDialog : : askSpeedLimit ( & ok , tr ( " Torrent Upload Speed Limiting " ) , default_limit , Preferences : : instance ( ) - > getGlobalUploadLimit ( ) * 1024. ) ;
const long new_limit = SpeedLimitDialog : : askSpeedLimit ( & ok , tr ( " Torrent Upload Speed Limiting " ) , default_limit , Preferences : : instance ( ) - > getGlobalUploadLimit ( ) * 1024. ) ;
if ( ok ) {
if ( ok ) {
foreach ( const QTorrentHandle & h , selected_torrents ) {
foreach ( const QTorrentHandle & h , selected_torrents ) {
qDebug ( " Applying upload speed limit of %ld Kb/s to torrent %s " , ( long ) ( new_limit / 1024. ) , qPrintable ( h . hash ( ) ) ) ;
qDebug ( " Applying upload speed limit of %ld Kb/s to torrent %s " , ( long ) ( new_limit / 1024. ) , qPrintable ( h . hash ( ) ) ) ;
BTSession - > setUploadLimit ( h . hash ( ) , new_limit ) ;
BTSession - > setUploadLimit ( h . hash ( ) , new_limit ) ;
}
}
}
}
}
}
void TransferListWidget : : setMaxRatioSelectedTorrents ( ) {
void TransferListWidget : : setMaxRatioSelectedTorrents ( )
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
if ( hashes . isEmpty ( ) )
if ( hashes . isEmpty ( ) )
return ;
return ;
@ -515,7 +529,8 @@ void TransferListWidget::setMaxRatioSelectedTorrents() {
qreal currentMaxRatio ;
qreal currentMaxRatio ;
if ( hashes . count ( ) = = 1 ) {
if ( hashes . count ( ) = = 1 ) {
currentMaxRatio = BTSession - > getMaxRatioPerTorrent ( hashes . first ( ) , & useGlobalValue ) ;
currentMaxRatio = BTSession - > getMaxRatioPerTorrent ( hashes . first ( ) , & useGlobalValue ) ;
} else {
}
else {
useGlobalValue = true ;
useGlobalValue = true ;
currentMaxRatio = BTSession - > getGlobalMaxRatio ( ) ;
currentMaxRatio = BTSession - > getGlobalMaxRatio ( ) ;
}
}
@ -530,22 +545,23 @@ 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 ) ;
{
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 )
if ( ret ! = QMessageBox : : Yes )
return ;
return ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes )
BTSession - > recheckTorrent ( hash ) ;
BTSession - > recheckTorrent ( hash ) ;
}
}
}
// hide/show columns menu
// hide/show columns menu
void TransferListWidget : : displayDLHoSMenu ( const QPoint & ) {
void TransferListWidget : : displayDLHoSMenu ( const QPoint & )
{
QMenu hideshowColumn ( this ) ;
QMenu hideshowColumn ( this ) ;
hideshowColumn . setTitle ( tr ( " Column visibility " ) ) ;
hideshowColumn . setTitle ( tr ( " Column visibility " ) ) ;
QList < QAction * > actions ;
QList < QAction * > actions ;
for ( int i = 0 ; i < listModel - > columnCount ( ) ; + + i ) {
for ( int i = 0 ; i < listModel - > columnCount ( ) ; + + i ) {
if ( ! BTSession - > isQueueingEnabled ( ) & & i = = TorrentModelItem : : TR_PRIORITY ) {
if ( ! BTSession - > isQueueingEnabled ( ) & & i = = TorrentModelItem : : TR_PRIORITY ) {
actions . append ( 0 ) ;
actions . append ( 0 ) ;
continue ;
continue ;
@ -556,7 +572,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
actions . append ( myAct ) ;
actions . append ( myAct ) ;
}
}
int visibleCols = 0 ;
int visibleCols = 0 ;
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + ) {
for ( unsigned int i = 0 ; i < TorrentModelItem : : NB_COLUMNS ; i + + ) {
if ( ! isColumnHidden ( i ) )
if ( ! isColumnHidden ( i ) )
visibleCols + + ;
visibleCols + + ;
@ -579,17 +595,18 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
}
}
}
}
void TransferListWidget : : toggleSelectedTorrentsSuperSeeding ( ) const {
void TransferListWidget : : toggleSelectedTorrentsSuperSeeding ( ) const
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
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 ) ;
h . super_seeding ( ! h . status ( 0 ) . super_seeding ) ;
}
}
}
}
}
void TransferListWidget : : toggleSelectedTorrentsSequentialDownload ( ) const {
void TransferListWidget : : toggleSelectedTorrentsSequentialDownload ( ) const
{
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
const QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
@ -602,17 +619,18 @@ void TransferListWidget::toggleSelectedTorrentsSequentialDownload() const {
}
}
}
}
void TransferListWidget : : toggleSelectedFirstLastPiecePrio ( ) const {
void TransferListWidget : : toggleSelectedFirstLastPiecePrio ( ) const
{
QStringList hashes = getSelectedTorrentsHashes ( ) ;
QStringList hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
QTorrentHandle h = BTSession - > getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) & & h . has_metadata ( ) ) {
if ( h . is_valid ( ) & & h . has_metadata ( ) )
h . prioritize_first_last_piece ( ! h . first_last_piece_first ( ) ) ;
h . prioritize_first_last_piece ( ! h . first_last_piece_first ( ) ) ;
}
}
}
}
}
void TransferListWidget : : askNewLabelForSelection ( ) {
void TransferListWidget : : askNewLabelForSelection ( )
{
// Ask for label
// Ask for label
bool ok ;
bool ok ;
bool invalid ;
bool invalid ;
@ -622,15 +640,17 @@ void TransferListWidget::askNewLabelForSelection() {
if ( ok & & ! label . isEmpty ( ) ) {
if ( ok & & ! label . isEmpty ( ) ) {
if ( fsutils : : isValidFileSystemName ( label ) ) {
if ( fsutils : : isValidFileSystemName ( label ) ) {
setSelectionLabel ( label ) ;
setSelectionLabel ( label ) ;
} else {
}
else {
QMessageBox : : warning ( this , tr ( " Invalid label name " ) , tr ( " Please don't use any special characters in the label name. " ) ) ;
QMessageBox : : warning ( this , tr ( " Invalid label name " ) , tr ( " Please don't use any special characters in the label name. " ) ) ;
invalid = true ;
invalid = true ;
}
}
}
}
} while ( invalid ) ;
} while ( invalid ) ;
}
}
bool TransferListWidget : : openUrl ( const QString & _path ) const {
bool TransferListWidget : : openUrl ( const QString & _path ) const
{
const QString path = fsutils : : fromNativePath ( _path ) ;
const QString path = fsutils : : fromNativePath ( _path ) ;
// Hack to access samba shares with QDesktopServices::openUrl
// Hack to access samba shares with QDesktopServices::openUrl
if ( path . startsWith ( " // " ) )
if ( path . startsWith ( " // " ) )
@ -639,7 +659,8 @@ bool TransferListWidget::openUrl(const QString &_path) const {
return QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( path ) ) ;
return QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( path ) ) ;
}
}
void TransferListWidget : : renameSelectedTorrent ( ) {
void TransferListWidget : : renameSelectedTorrent ( )
{
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
const QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
if ( selectedIndexes . size ( ) ! = 1 ) return ;
if ( selectedIndexes . size ( ) ! = 1 ) return ;
if ( ! selectedIndexes . first ( ) . isValid ( ) ) return ;
if ( ! selectedIndexes . first ( ) . isValid ( ) ) return ;
@ -657,7 +678,8 @@ void TransferListWidget::renameSelectedTorrent() {
}
}
}
}
void TransferListWidget : : setSelectionLabel ( QString label ) {
void TransferListWidget : : setSelectionLabel ( QString label )
{
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
const QStringList & hashes = getSelectedTorrentsHashes ( ) ;
foreach ( const QString & hash , hashes ) {
foreach ( const QString & hash , hashes ) {
Q_ASSERT ( ! hash . isEmpty ( ) ) ;
Q_ASSERT ( ! hash . isEmpty ( ) ) ;
@ -670,8 +692,9 @@ void TransferListWidget::setSelectionLabel(QString label) {
}
}
}
}
void TransferListWidget : : removeLabelFromRows ( QString label ) {
void TransferListWidget : : removeLabelFromRows ( QString label )
for ( int i = 0 ; i < listModel - > rowCount ( ) ; + + i ) {
{
for ( int i = 0 ; i < listModel - > rowCount ( ) ; + + i ) {
if ( listModel - > data ( listModel - > index ( i , TorrentModelItem : : TR_LABEL ) ) = = label ) {
if ( listModel - > data ( listModel - > index ( i , TorrentModelItem : : TR_LABEL ) ) = = label ) {
const QString hash = getHashFromRow ( i ) ;
const QString hash = getHashFromRow ( i ) ;
listModel - > setData ( listModel - > index ( i , TorrentModelItem : : TR_LABEL ) , " " , Qt : : DisplayRole ) ;
listModel - > setData ( listModel - > index ( i , TorrentModelItem : : TR_LABEL ) , " " , Qt : : DisplayRole ) ;
@ -682,7 +705,8 @@ void TransferListWidget::removeLabelFromRows(QString label) {
}
}
}
}
void TransferListWidget : : displayListMenu ( const QPoint & ) {
void TransferListWidget : : displayListMenu ( const QPoint & )
{
QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
QModelIndexList selectedIndexes = selectionModel ( ) - > selectedRows ( ) ;
if ( selectedIndexes . size ( ) = = 0 )
if ( selectedIndexes . size ( ) = = 0 )
return ;
return ;
@ -754,25 +778,23 @@ void TransferListWidget::displayListMenu(const QPoint&) {
if ( first ) {
if ( first ) {
sequential_download_mode = h . is_sequential_download ( ) ;
sequential_download_mode = h . is_sequential_download ( ) ;
prioritize_first_last = h . first_last_piece_first ( ) ;
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 ;
all_same_prio_firstlast = false ;
}
}
}
}
}
}
}
else {
else {
if ( ! one_not_seed & & all_same_super_seeding & & h . has_metadata ( ) ) {
if ( ! one_not_seed & & all_same_super_seeding & & h . has_metadata ( ) ) {
if ( first ) {
if ( first ) {
super_seeding_mode = h . status ( 0 ) . super_seeding ;
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 ( ) ) {
if ( h . is_paused ( ) ) {
@ -780,15 +802,15 @@ void TransferListWidget::displayListMenu(const QPoint&) {
listMenu . addAction ( & actionStart ) ;
listMenu . addAction ( & actionStart ) ;
has_start = true ;
has_start = true ;
}
}
} else {
}
else {
if ( ! has_pause ) {
if ( ! has_pause ) {
listMenu . addAction ( & actionPause ) ;
listMenu . addAction ( & actionPause ) ;
has_pause = true ;
has_pause = true ;
}
}
}
}
if ( h . has_metadata ( ) & & BTSession - > isFilePreviewPossible ( hash ) & & ! has_preview ) {
if ( h . has_metadata ( ) & & BTSession - > isFilePreviewPossible ( hash ) & & ! has_preview )
has_preview = true ;
has_preview = true ;
}
first = false ;
first = false ;
if ( has_pause & & has_start & & has_preview & & one_not_seed ) break ;
if ( has_pause & & has_start & & has_preview & & one_not_seed ) break ;
}
}
@ -806,9 +828,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " list-add " ) , tr ( " New... " , " New label... " ) ) ;
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " list-add " ) , tr ( " New... " , " New label... " ) ) ;
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " edit-clear " ) , tr ( " Reset " , " Reset label " ) ) ;
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " edit-clear " ) , tr ( " Reset " , " Reset label " ) ) ;
labelMenu - > addSeparator ( ) ;
labelMenu - > addSeparator ( ) ;
foreach ( const QString & label , customLabels ) {
foreach ( const QString & label , customLabels )
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) , label ) ;
labelActions < < labelMenu - > addAction ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) , label ) ;
}
listMenu . addSeparator ( ) ;
listMenu . addSeparator ( ) ;
if ( one_not_seed )
if ( one_not_seed )
listMenu . addAction ( & actionSet_download_limit ) ;
listMenu . addAction ( & actionSet_download_limit ) ;
@ -864,10 +885,11 @@ void TransferListWidget::displayListMenu(const QPoint&) {
if ( i = = 0 ) {
if ( i = = 0 ) {
// New Label
// New Label
askNewLabelForSelection ( ) ;
askNewLabelForSelection ( ) ;
} else {
}
else {
QString label = " " ;
QString label = " " ;
if ( i > 1 )
if ( i > 1 )
label = customLabels . at ( i - 2 ) ;
label = customLabels . at ( i - 2 ) ;
// Update Label
// Update Label
setSelectionLabel ( label ) ;
setSelectionLabel ( label ) ;
}
}
@ -875,7 +897,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 " ) ;
qDebug ( " CURRENT CHANGED " ) ;
QTorrentHandle h ;
QTorrentHandle h ;
if ( current . isValid ( ) ) {
if ( current . isValid ( ) ) {
@ -887,25 +910,29 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel
emit currentTorrentChanged ( h ) ;
emit currentTorrentChanged ( h ) ;
}
}
void TransferListWidget : : applyLabelFilterAll ( ) {
void TransferListWidget : : applyLabelFilterAll ( )
{
nameFilterModel - > disableLabelFilter ( ) ;
nameFilterModel - > disableLabelFilter ( ) ;
}
}
void TransferListWidget : : applyLabelFilter ( QString label ) {
void TransferListWidget : : applyLabelFilter ( QString label )
{
qDebug ( " Applying Label filter: %s " , qPrintable ( label ) ) ;
qDebug ( " Applying Label filter: %s " , qPrintable ( label ) ) ;
nameFilterModel - > setLabelFilter ( label ) ;
nameFilterModel - > setLabelFilter ( label ) ;
}
}
void TransferListWidget : : applyNameFilter ( const QString & name ) {
void TransferListWidget : : applyNameFilter ( const QString & name )
{
nameFilterModel - > setFilterRegExp ( QRegExp ( QRegExp : : escape ( name ) , Qt : : CaseInsensitive ) ) ;
nameFilterModel - > setFilterRegExp ( QRegExp ( QRegExp : : escape ( name ) , Qt : : CaseInsensitive ) ) ;
}
}
void TransferListWidget : : applyStatusFilter ( int f ) {
void TransferListWidget : : applyStatusFilter ( int f )
{
nameFilterModel - > setStatusFilter ( ( TorrentFilter : : TorrentFilter ) f ) ;
nameFilterModel - > setStatusFilter ( ( TorrentFilter : : TorrentFilter ) f ) ;
// Select first item if nothing is selected
// Select first item if nothing is selected
if ( selectionModel ( ) - > selectedRows ( 0 ) . empty ( ) & & nameFilterModel - > rowCount ( ) > 0 ) {
if ( selectionModel ( ) - > selectedRows ( 0 ) . empty ( ) & & nameFilterModel - > rowCount ( ) > 0 ) {
qDebug ( " Nothing is selected, selecting first row: %s " , qPrintable ( nameFilterModel - > index ( 0 , TorrentModelItem : : TR_NAME ) . data ( ) . toString ( ) ) ) ;
qDebug ( " Nothing is selected, selecting first row: %s " , qPrintable ( nameFilterModel - > index ( 0 , TorrentModelItem : : TR_NAME ) . data ( ) . toString ( ) ) ) ;
selectionModel ( ) - > setCurrentIndex ( nameFilterModel - > index ( 0 , TorrentModelItem : : TR_NAME ) , QItemSelectionModel : : SelectCurrent | QItemSelectionModel : : Rows ) ;
selectionModel ( ) - > setCurrentIndex ( nameFilterModel - > index ( 0 , TorrentModelItem : : TR_NAME ) , QItemSelectionModel : : SelectCurrent | QItemSelectionModel : : Rows ) ;
}
}
}
}
@ -917,9 +944,8 @@ void TransferListWidget::saveSettings()
bool TransferListWidget : : loadSettings ( )
bool TransferListWidget : : loadSettings ( )
{
{
bool ok = header ( ) - > restoreState ( Preferences : : instance ( ) - > getTransHeaderState ( ) ) ;
bool ok = header ( ) - > restoreState ( Preferences : : instance ( ) - > getTransHeaderState ( ) ) ;
if ( ! ok ) {
if ( ! ok )
header ( ) - > resizeSection ( 0 , 200 ) ; // Default
header ( ) - > resizeSection ( 0 , 200 ) ; // Default
}
return ok ;
return ok ;
}
}