Ticket #2050: qt_refresh.patch

File qt_refresh.patch, 5.8 KB (added by Longinus00, 13 years ago)
  • qt/details.cc

    diff --git qt/details.cc qt/details.cc
    index 1f98894..a16ea42 100644
    Details :: Details( Session& session, Prefs& prefs, TorrentModel& model, QWidget 
    123123    mySession( session ),
    124124    myPrefs( prefs ),
    125125    myModel( model ),
     126    myChangedTorrents( false ),
    126127    myHavePendingRefresh( false )
    127128{
    128129    QVBoxLayout * layout = new QVBoxLayout( this );
    Details :: setIds( const QSet<int>& ids ) 
    164165    if( ids == myIds )
    165166        return;
    166167
     168    myChangedTorrents = true;
     169
    167170    // stop listening to the old torrents
    168171    foreach( int id, myIds ) {
    169172        const Torrent * tor = myModel.getTorrentFromId( id );
    Details :: refresh( ) 
    534537    ///  Options Tab
    535538    ///
    536539
    537     if( !torrents.empty( ) )
     540    if( myChangedTorrents && !torrents.empty( ) )
    538541    {
    539542        int i;
    540543        const Torrent * baseline = *torrents.begin();
    Details :: refresh( ) 
    832835    myPeers = peers2;
    833836
    834837    if( single )
    835         myFileTreeView->update( torrents[0]->files( ) );
     838    {
     839        myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents );
     840    }
    836841    else
    837842        myFileTreeView->clear( );
    838843
     844    myChangedTorrents = false;
    839845    myHavePendingRefresh = false;
    840846    foreach( QWidget * w, myWidgets )
    841847        w->setEnabled( true );
  • qt/details.h

    diff --git qt/details.h qt/details.h
    index 51d494d..3702ffd 100644
    class Details: public QDialog 
    6969        TorrentModel& myModel;
    7070        QSet<int> myIds;
    7171        QTimer myTimer;
     72        bool myChangedTorrents;
    7273        bool myHavePendingRefresh;
    7374
    7475        QLabel * myStateLabel;
  • qt/file-tree.cc

    diff --git qt/file-tree.cc qt/file-tree.cc
    index 6eb5df4..0a27b8c 100644
    FileTreeItem :: fileSizeName( ) const 
    127127}
    128128
    129129bool
    130 FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize, uint64_t haveSize )
     130FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize, uint64_t haveSize, bool torrentChanged )
    131131{
    132132    bool changed = false;
    133133
    FileTreeItem :: update( int index, bool wanted, int priority, uint64_t totalSize 
    136136        myIndex = index;
    137137        changed = true;
    138138    }
    139     if( myIsWanted != wanted )
     139    if( torrentChanged && myIsWanted != wanted )
    140140    {
    141141        myIsWanted = wanted;
    142142        changed = true;
    143143    }
    144     if( myPriority != priority )
     144    if( torrentChanged && myPriority != priority )
    145145    {
    146146        myPriority = priority;
    147147        changed = true;
    FileTreeModel :: addFile( int index, 
    413413                          int                   priority,
    414414                          uint64_t              size,
    415415                          uint64_t              have,
    416                           QList<QModelIndex>  & rowsAdded )
     416                          QList<QModelIndex>  & rowsAdded,
     417                          bool                  torrentChanged )
    417418{
    418419    FileTreeItem * i( rootItem );
    419420
    FileTreeModel :: addFile( int index, 
    433434    }
    434435
    435436    if( i != rootItem )
    436         if( i->update( index, wanted, priority, size, have ) )
     437        if( i->update( index, wanted, priority, size, have, torrentChanged ) )
    437438            dataChanged( indexOf( i, 0 ), indexOf( i, NUM_COLUMNS-1 ) );
    438439}
    439440
    FileTreeView :: eventFilter( QObject * o, QEvent * event ) 
    647648void
    648649FileTreeView :: update( const FileList& files )
    649650{
     651    update( files, true );
     652}
     653
     654void
     655FileTreeView :: update( const FileList& files, bool torrentChanged )
     656{
    650657    foreach( const TrFile file, files ) {
    651658        QList<QModelIndex> added;
    652         myModel.addFile( file.index, file.filename, file.wanted, file.priority, file.size, file.have, added );
     659        myModel.addFile( file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, torrentChanged );
    653660        foreach( QModelIndex i, added )
    654661            expand( i );
    655662    }
  • qt/file-tree.h

    diff --git qt/file-tree.h qt/file-tree.h
    index 7714afc..11c07ea 100644
    class FileTreeItem: public QObject 
    5151        int row( ) const;
    5252        const QString& name( ) const { return myName; }
    5353        QVariant data( int column ) const;
    54         bool update( int index, bool want, int priority, uint64_t total, uint64_t have );
     54        bool update( int index, bool want, int priority, uint64_t total, uint64_t have, bool torrentChanged );
    5555        void twiddleWanted( QSet<int>& fileIds, bool& );
    5656        void twiddlePriority( QSet<int>& fileIds, int& );
    5757
    class FileTreeModel: public QAbstractItemModel 
    102102        void addFile( int index, const QString& filename,
    103103                      bool wanted, int priority,
    104104                      uint64_t size, uint64_t have,
    105                       QList<QModelIndex>& rowsAdded );
     105                      QList<QModelIndex>& rowsAdded,
     106                      bool torrentChanged );
    106107
    107108    private:
    108109        void clearSubtree( const QModelIndex & );
    class FileTreeView: public QTreeView 
    140141        virtual ~FileTreeView( ) { }
    141142        void clear( );
    142143        void update( const FileList& files );
     144        void update( const FileList& files, bool torrentChanged );
    143145
    144146    signals:
    145147        void priorityChanged( const QSet<int>& fileIndices, int );
  • qt/prefs-dialog.cc

    diff --git qt/prefs-dialog.cc qt/prefs-dialog.cc
    index 89715ae..68adf26 100644
    PrefsDialog :: PrefsDialog( Session& session, Prefs& prefs, QWidget * parent ): 
    623623    connect( buttons, SIGNAL(rejected()), this, SLOT(hide()) ); // "close" triggers rejected
    624624    myLayout->addWidget( buttons );
    625625
    626     connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int)));
    627626    connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated()));
    628627
    629628    QList<int> keys;