1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-03 02:05:19 +00:00

(trunk Qt) #2050 "Properties dialog changes seem to undo themselves" -- use patch from Longinus00

This commit is contained in:
Charles Kerr 2010-05-05 09:41:14 +00:00
parent 017b5cad86
commit 91e3187d3b
5 changed files with 26 additions and 11 deletions

View file

@ -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<int>& 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 );

View file

@ -69,6 +69,7 @@ class Details: public QDialog
TorrentModel& myModel;
QSet<int> myIds;
QTimer myTimer;
bool myChangedTorrents;
bool myHavePendingRefresh;
QLabel * myStateLabel;

View file

@ -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<QModelIndex> & rowsAdded )
QList<QModelIndex> & 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<QModelIndex> 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 );
}

View file

@ -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<int>& fileIds, bool& );
void twiddlePriority( QSet<int>& 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<QModelIndex>& rowsAdded );
QList<QModelIndex>& 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<int>& fileIndices, int );

View file

@ -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<int> keys;