From 91e3187d3b3fc7ed16d732fd85c4f14f8b81e906 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 5 May 2010 09:41:14 +0000 Subject: [PATCH] (trunk Qt) #2050 "Properties dialog changes seem to undo themselves" -- use patch from Longinus00 --- qt/details.cc | 10 ++++++++-- qt/details.h | 1 + qt/file-tree.cc | 19 +++++++++++++------ qt/file-tree.h | 6 ++++-- qt/prefs-dialog.cc | 1 - 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/qt/details.cc b/qt/details.cc index 1f98894db..a16ea425c 100644 --- a/qt/details.cc +++ b/qt/details.cc @@ -123,6 +123,7 @@ Details :: Details( Session& session, Prefs& prefs, TorrentModel& model, QWidget mySession( session ), myPrefs( prefs ), myModel( model ), + myChangedTorrents( false ), myHavePendingRefresh( false ) { QVBoxLayout * layout = new QVBoxLayout( this ); @@ -164,6 +165,8 @@ Details :: setIds( const QSet& ids ) if( ids == myIds ) return; + myChangedTorrents = true; + // stop listening to the old torrents foreach( int id, myIds ) { const Torrent * tor = myModel.getTorrentFromId( id ); @@ -534,7 +537,7 @@ Details :: refresh( ) /// Options Tab /// - if( !torrents.empty( ) ) + if( myChangedTorrents && !torrents.empty( ) ) { int i; const Torrent * baseline = *torrents.begin(); @@ -832,10 +835,13 @@ Details :: refresh( ) myPeers = peers2; if( single ) - myFileTreeView->update( torrents[0]->files( ) ); + { + myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents ); + } else myFileTreeView->clear( ); + myChangedTorrents = false; myHavePendingRefresh = false; foreach( QWidget * w, myWidgets ) w->setEnabled( true ); diff --git a/qt/details.h b/qt/details.h index 51d494d01..3702ffd53 100644 --- a/qt/details.h +++ b/qt/details.h @@ -69,6 +69,7 @@ class Details: public QDialog TorrentModel& myModel; QSet myIds; QTimer myTimer; + bool myChangedTorrents; bool myHavePendingRefresh; QLabel * myStateLabel; diff --git a/qt/file-tree.cc b/qt/file-tree.cc index 6eb5df49a..0a27b8c01 100644 --- a/qt/file-tree.cc +++ b/qt/file-tree.cc @@ -127,7 +127,7 @@ FileTreeItem :: fileSizeName( ) const } bool -FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize, uint64_t haveSize ) +FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize, uint64_t haveSize, bool torrentChanged ) { bool changed = false; @@ -136,12 +136,12 @@ FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize myIndex = index; changed = true; } - if( myIsWanted != wanted ) + if( torrentChanged && myIsWanted != wanted ) { myIsWanted = wanted; changed = true; } - if( myPriority != priority ) + if( torrentChanged && myPriority != priority ) { myPriority = priority; changed = true; @@ -413,7 +413,8 @@ FileTreeModel :: addFile( int index, int priority, uint64_t size, uint64_t have, - QList & rowsAdded ) + QList & rowsAdded, + bool torrentChanged ) { FileTreeItem * i( rootItem ); @@ -433,7 +434,7 @@ FileTreeModel :: addFile( int index, } if( i != rootItem ) - if( i->update( index, wanted, priority, size, have ) ) + if( i->update( index, wanted, priority, size, have, torrentChanged ) ) dataChanged( indexOf( i, 0 ), indexOf( i, NUM_COLUMNS-1 ) ); } @@ -646,10 +647,16 @@ FileTreeView :: eventFilter( QObject * o, QEvent * event ) void FileTreeView :: update( const FileList& files ) +{ + update( files, true ); +} + +void +FileTreeView :: update( const FileList& files, bool torrentChanged ) { foreach( const TrFile file, files ) { QList added; - myModel.addFile( file.index, file.filename, file.wanted, file.priority, file.size, file.have, added ); + myModel.addFile( file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, torrentChanged ); foreach( QModelIndex i, added ) expand( i ); } diff --git a/qt/file-tree.h b/qt/file-tree.h index 7714afccd..11c07ea41 100644 --- a/qt/file-tree.h +++ b/qt/file-tree.h @@ -51,7 +51,7 @@ class FileTreeItem: public QObject int row( ) const; const QString& name( ) const { return myName; } QVariant data( int column ) const; - bool update( int index, bool want, int priority, uint64_t total, uint64_t have ); + bool update( int index, bool want, int priority, uint64_t total, uint64_t have, bool torrentChanged ); void twiddleWanted( QSet& fileIds, bool& ); void twiddlePriority( QSet& fileIds, int& ); @@ -102,7 +102,8 @@ class FileTreeModel: public QAbstractItemModel void addFile( int index, const QString& filename, bool wanted, int priority, uint64_t size, uint64_t have, - QList& rowsAdded ); + QList& rowsAdded, + bool torrentChanged ); private: void clearSubtree( const QModelIndex & ); @@ -140,6 +141,7 @@ class FileTreeView: public QTreeView virtual ~FileTreeView( ) { } void clear( ); void update( const FileList& files ); + void update( const FileList& files, bool torrentChanged ); signals: void priorityChanged( const QSet& fileIndices, int ); diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index 89715ae8b..68adf26b1 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -623,7 +623,6 @@ PrefsDialog :: PrefsDialog( Session& session, Prefs& prefs, QWidget * parent ): connect( buttons, SIGNAL(rejected()), this, SLOT(hide()) ); // "close" triggers rejected myLayout->addWidget( buttons ); - connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int))); connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated())); QList keys; -- 2.40.0