1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-03 10:15:45 +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 ), mySession( session ),
myPrefs( prefs ), myPrefs( prefs ),
myModel( model ), myModel( model ),
myChangedTorrents( false ),
myHavePendingRefresh( false ) myHavePendingRefresh( false )
{ {
QVBoxLayout * layout = new QVBoxLayout( this ); QVBoxLayout * layout = new QVBoxLayout( this );
@ -164,6 +165,8 @@ Details :: setIds( const QSet<int>& ids )
if( ids == myIds ) if( ids == myIds )
return; return;
myChangedTorrents = true;
// stop listening to the old torrents // stop listening to the old torrents
foreach( int id, myIds ) { foreach( int id, myIds ) {
const Torrent * tor = myModel.getTorrentFromId( id ); const Torrent * tor = myModel.getTorrentFromId( id );
@ -534,7 +537,7 @@ Details :: refresh( )
/// Options Tab /// Options Tab
/// ///
if( !torrents.empty( ) ) if( myChangedTorrents && !torrents.empty( ) )
{ {
int i; int i;
const Torrent * baseline = *torrents.begin(); const Torrent * baseline = *torrents.begin();
@ -832,10 +835,13 @@ Details :: refresh( )
myPeers = peers2; myPeers = peers2;
if( single ) if( single )
myFileTreeView->update( torrents[0]->files( ) ); {
myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents );
}
else else
myFileTreeView->clear( ); myFileTreeView->clear( );
myChangedTorrents = false;
myHavePendingRefresh = false; myHavePendingRefresh = false;
foreach( QWidget * w, myWidgets ) foreach( QWidget * w, myWidgets )
w->setEnabled( true ); w->setEnabled( true );

View file

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

View file

@ -127,7 +127,7 @@ FileTreeItem :: fileSizeName( ) const
} }
bool 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; bool changed = false;
@ -136,12 +136,12 @@ FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize
myIndex = index; myIndex = index;
changed = true; changed = true;
} }
if( myIsWanted != wanted ) if( torrentChanged && myIsWanted != wanted )
{ {
myIsWanted = wanted; myIsWanted = wanted;
changed = true; changed = true;
} }
if( myPriority != priority ) if( torrentChanged && myPriority != priority )
{ {
myPriority = priority; myPriority = priority;
changed = true; changed = true;
@ -413,7 +413,8 @@ FileTreeModel :: addFile( int index,
int priority, int priority,
uint64_t size, uint64_t size,
uint64_t have, uint64_t have,
QList<QModelIndex> & rowsAdded ) QList<QModelIndex> & rowsAdded,
bool torrentChanged )
{ {
FileTreeItem * i( rootItem ); FileTreeItem * i( rootItem );
@ -433,7 +434,7 @@ FileTreeModel :: addFile( int index,
} }
if( i != rootItem ) 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 ) ); dataChanged( indexOf( i, 0 ), indexOf( i, NUM_COLUMNS-1 ) );
} }
@ -646,10 +647,16 @@ FileTreeView :: eventFilter( QObject * o, QEvent * event )
void void
FileTreeView :: update( const FileList& files ) FileTreeView :: update( const FileList& files )
{
update( files, true );
}
void
FileTreeView :: update( const FileList& files, bool torrentChanged )
{ {
foreach( const TrFile file, files ) { foreach( const TrFile file, files ) {
QList<QModelIndex> added; 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 ) foreach( QModelIndex i, added )
expand( i ); expand( i );
} }

View file

@ -51,7 +51,7 @@ class FileTreeItem: public QObject
int row( ) const; int row( ) const;
const QString& name( ) const { return myName; } const QString& name( ) const { return myName; }
QVariant data( int column ) const; 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 twiddleWanted( QSet<int>& fileIds, bool& );
void twiddlePriority( QSet<int>& fileIds, int& ); void twiddlePriority( QSet<int>& fileIds, int& );
@ -102,7 +102,8 @@ class FileTreeModel: public QAbstractItemModel
void addFile( int index, const QString& filename, void addFile( int index, const QString& filename,
bool wanted, int priority, bool wanted, int priority,
uint64_t size, uint64_t have, uint64_t size, uint64_t have,
QList<QModelIndex>& rowsAdded ); QList<QModelIndex>& rowsAdded,
bool torrentChanged );
private: private:
void clearSubtree( const QModelIndex & ); void clearSubtree( const QModelIndex & );
@ -140,6 +141,7 @@ class FileTreeView: public QTreeView
virtual ~FileTreeView( ) { } virtual ~FileTreeView( ) { }
void clear( ); void clear( );
void update( const FileList& files ); void update( const FileList& files );
void update( const FileList& files, bool torrentChanged );
signals: signals:
void priorityChanged( const QSet<int>& fileIndices, int ); 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 connect( buttons, SIGNAL(rejected()), this, SLOT(hide()) ); // "close" triggers rejected
myLayout->addWidget( buttons ); myLayout->addWidget( buttons );
connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int)));
connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated())); connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated()));
QList<int> keys; QList<int> keys;