From f6672e8911153157db7fb569f849660048515489 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 9 Apr 2009 22:42:55 +0000 Subject: [PATCH] (trunk qt,gtk) include torrents-being-verified in the "active torrents" filter. --- gtk/tr-window.c | 4 +++- qt/prefs-dialog.cc | 17 ++++++++++++++--- qt/prefs-dialog.h | 1 + qt/session.cc | 2 +- qt/torrent-delegate.cc | 3 +-- qt/torrent-filter.cc | 2 +- qt/torrent.h | 3 ++- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 4b871e899..4322def24 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -372,7 +372,9 @@ checkFilterMode( filter_mode_t filter_mode, case FILTER_MODE_ACTIVE: { const tr_stat * s = tr_torrentStatCached( tor ); - ret = s->peersSendingToUs > 0 || s->peersGettingFromUs > 0; + ret = s->peersSendingToUs > 0 + || s->peersGettingFromUs > 0 + || tr_torrentGetActivity( tor ) == TR_STATUS_CHECK; break; } diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index da7400ee8..e095b7377 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -444,7 +444,7 @@ PrefsDialog :: createPeersTab( const Session& session ) QPushButton * w = new QPushButton( i, tr( "&Update blocklist" ) ); connect( w, SIGNAL(clicked(bool)), this, SLOT(onUpdateBlocklistClicked())); myBlockWidgets << w; - QWidget * l = checkBoxNew( tr( "Enable &blocklist (contains %Ln rule(s))", 0, session.blocklistSize( ) ), Prefs::BLOCKLIST_ENABLED ); + QWidget * l = checkBoxNew( "", Prefs::BLOCKLIST_ENABLED ); h->addWidget( l ); h->addStretch( 1 ); h->addWidget( w ); @@ -471,7 +471,7 @@ PrefsDialog :: createPeersTab( const Session& session ) hig->addWideControl( checkBoxNew( tr( "Use peer e&xchange" ), Prefs::PEX_ENABLED ) ); hig->finish( ); - myUnsupportedWhenRemote << myBlockWidgets; + updateBlocklistCheckBox( ); return hig; } @@ -617,9 +617,19 @@ PrefsDialog :: ~PrefsDialog( ) void PrefsDialog :: sessionUpdated( ) +{ + updateBlocklistCheckBox( ); +} + +void +PrefsDialog :: updateBlocklistCheckBox( ) { QCheckBox * box = qobject_cast( myWidgets[Prefs::BLOCKLIST_ENABLED] ); - box->setText( tr( "Enable &blocklist (%Ln rules)", 0, mySession.blocklistSize( ) ) ); + const int n = mySession.blocklistSize( ); + if( n < 0 ) // unknown + box->setText( tr( "Enable &blocklist" ) ); + else + box->setText( tr( "Enable &blocklist (%Ln rules)", 0, n ) ); } void @@ -656,6 +666,7 @@ PrefsDialog :: updatePref( int key ) case Prefs :: BLOCKLIST_ENABLED: { const bool enabled = myPrefs.getBool( key ); + std::cerr << " setting " << myBlockWidgets.size() << " block widgets to " << enabled << std::endl; foreach( QWidget * w, myBlockWidgets ) w->setEnabled( enabled ); break; } diff --git a/qt/prefs-dialog.h b/qt/prefs-dialog.h index 8b45a0412..2399d67e4 100644 --- a/qt/prefs-dialog.h +++ b/qt/prefs-dialog.h @@ -69,6 +69,7 @@ class PrefsDialog: public QDialog QTimeEdit * timeEditNew( int key ); QLineEdit * lineEditNew( int key, int mode = 0 ); void enableBuddyWhenChecked( QCheckBox *, QWidget * ); + void updateBlocklistCheckBox( ); public: PrefsDialog( Session&, Prefs&, QWidget * parent = 0 ); diff --git a/qt/session.cc b/qt/session.cc index 218688f52..3ea348f98 100644 --- a/qt/session.cc +++ b/qt/session.cc @@ -174,7 +174,7 @@ std::cerr << "setting whitelist" << std::endl; ***/ Session :: Session( const char * configDir, Prefs& prefs, const char * url, bool paused ): - myBlocklistSize( ), + myBlocklistSize( -1 ), myPrefs( prefs ), mySession( 0 ), myUrl( url ) diff --git a/qt/torrent-delegate.cc b/qt/torrent-delegate.cc index 27acdfa43..82081f938 100644 --- a/qt/torrent-delegate.cc +++ b/qt/torrent-delegate.cc @@ -218,10 +218,9 @@ TorrentDelegate :: statusString( const Torrent& tor ) const break; } - if( !tor.isChecking( ) && !tor.isPaused( ) ) + if( tor.isReadyToTransfer( ) ) str += tr( " - " ) + shortTransferString( tor ); - //str += "asdfasdf"; return str; } diff --git a/qt/torrent-filter.cc b/qt/torrent-filter.cc index 9019f88bc..d23071521 100644 --- a/qt/torrent-filter.cc +++ b/qt/torrent-filter.cc @@ -80,7 +80,7 @@ TorrentFilter :: filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen accepts = true; break; case SHOW_ACTIVE: - accepts = tor->peersWeAreUploadingTo( ) > 0 || tor->peersWeAreDownloadingFrom( ) > 0; + accepts = tor->peersWeAreUploadingTo( ) > 0 || tor->peersWeAreDownloadingFrom( ) > 0 || tor->isVerifying( ); break; case SHOW_DOWNLOADING: accepts = activity == TR_STATUS_DOWNLOAD; diff --git a/qt/torrent.h b/qt/torrent.h index 0d5545fa5..a3b9d721a 100644 --- a/qt/torrent.h +++ b/qt/torrent.h @@ -271,8 +271,9 @@ class Torrent: public QObject QString activityString( ) const; tr_torrent_activity getActivity( ) const { return (tr_torrent_activity) getInt( ACTIVITY ); } bool isPaused( ) const { return getActivity( ) == TR_STATUS_STOPPED; } - bool isChecking( ) const { return getActivity( ) == TR_STATUS_CHECK || getActivity( ) == TR_STATUS_CHECK_WAIT; } + bool isVerifying( ) const { return getActivity( ) == TR_STATUS_CHECK; } bool isDownloading( ) const { return getActivity( ) == TR_STATUS_DOWNLOAD; } + bool isReadyToTransfer( ) const { return getActivity()==TR_STATUS_DOWNLOAD || getActivity()==TR_STATUS_SEED; } void notifyComplete( ) const; public: -- 2.40.0