Changeset 12557


Ignore:
Timestamp:
Jul 19, 2011, 9:19:18 PM (10 years ago)
Author:
jordan
Message:

(trunk qt) #4369 "Typing text into the main window's filter field causes high CPU" -- fixed.

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r12546 r12557  
    9292    myLastReadTime( 0 ),
    9393    myNetworkTimer( this ),
    94     myRefreshTrayIconTimer( this )
     94    myRefreshTrayIconTimer( this ),
     95    myRefreshActionSensitivityTimer( this )
    9596{
    9697    setAcceptDrops( true );
     
    191192    connect( &myFilterModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(refreshVisibleCount()));
    192193    connect( &myFilterModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(refreshVisibleCount()));
    193     connect( &myFilterModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(refreshActionSensitivity()));
    194     connect( &myFilterModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(refreshActionSensitivity()));
     194    connect( &myFilterModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(refreshActionSensitivitySoon()));
     195    connect( &myFilterModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(refreshActionSensitivitySoon()));
    195196
    196197    connect( ui.action_Quit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit()) );
     
    204205
    205206    ui.listView->setModel( &myFilterModel );
    206     connect( ui.listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)), this, SLOT(refreshActionSensitivity()));
     207    connect( ui.listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)), this, SLOT(refreshActionSensitivitySoon()));
    207208
    208209    QActionGroup * actionGroup = new QActionGroup( this );
     
    276277
    277278    connect( &myRefreshTrayIconTimer, SIGNAL(timeout()), this, SLOT(refreshTrayIcon()) );
    278 
    279 
    280     refreshActionSensitivity( );
     279    connect( &myRefreshActionSensitivityTimer, SIGNAL(timeout()), this, SLOT(refreshActionSensitivity()) );
     280
     281
     282    refreshActionSensitivitySoon( );
    281283    refreshTrayIconSoon( );
    282284    refreshStatusBar( );
     
    321323    refreshTitle( );
    322324    refreshVisibleCount( );
    323     refreshActionSensitivity( );
     325    refreshActionSensitivitySoon( );
    324326    refreshStatusBar( );
    325327    refreshTrayIconSoon( );
     
    708710}
    709711
     712
     713
     714void
     715TrMainWindow :: refreshActionSensitivitySoon( )
     716{
     717    if( !myRefreshActionSensitivityTimer.isActive( ) )
     718    {
     719        myRefreshActionSensitivityTimer.setSingleShot( true );
     720        myRefreshActionSensitivityTimer.start( 500 );
     721    }
     722}
    710723void
    711724TrMainWindow :: refreshActionSensitivity( )
  • trunk/qt/mainwin.h

    r12546 r12557  
    7777        QTimer myNetworkTimer;
    7878        QTimer myRefreshTrayIconTimer;
     79        QTimer myRefreshActionSensitivityTimer;
    7980        QAction * myDlimitOffAction;
    8081        QAction * myDlimitOnAction;
     
    179180        void setCompactView( bool );
    180181        void refreshActionSensitivity( );
     182        void refreshActionSensitivitySoon( );
    181183        void wrongAuthentication( );
    182184
Note: See TracChangeset for help on using the changeset viewer.