mirror of
https://github.com/transmission/transmission
synced 2025-01-30 19:03:04 +00:00
perf: lazy-update actions enabled on change events (#1187)
* perf: lazy-update actions enabled on change events Actions' sensitivity was being lazy-updated in response to other events but accidentally were doing immediate updates in response to torrentsChanged signals being emitted from TorrentModel. This commit makes that path a lazy-update as well. * chore: uncrustify * refactor: make the idle updater a lambda again
This commit is contained in:
parent
87c9287b6a
commit
797700e63f
3 changed files with 7 additions and 6 deletions
|
@ -294,7 +294,6 @@ Application::Application(int& argc, char** argv) :
|
|||
myWatchDir = new WatchDir(*myModel);
|
||||
|
||||
connect(myModel, &TorrentModel::torrentsAdded, this, &Application::onTorrentsAdded);
|
||||
connect(myModel, &TorrentModel::torrentsChanged, myWindow, &MainWindow::refreshActionSensitivity);
|
||||
connect(myModel, &TorrentModel::torrentsCompleted, this, &Application::onTorrentsCompleted);
|
||||
connect(myModel, &TorrentModel::torrentsNeedInfo, this, &Application::onTorrentsNeedInfo);
|
||||
connect(myPrefs, &Prefs::changed, this, &Application::refreshPref);
|
||||
|
|
|
@ -245,6 +245,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
|||
auto refreshActionSensitivitySoon = [this]() { refreshSoon(REFRESH_ACTION_SENSITIVITY); };
|
||||
connect(&myFilterModel, &TorrentFilter::rowsInserted, this, refreshActionSensitivitySoon);
|
||||
connect(&myFilterModel, &TorrentFilter::rowsRemoved, this, refreshActionSensitivitySoon);
|
||||
connect(&myModel, &TorrentModel::torrentsChanged, this, refreshActionSensitivitySoon);
|
||||
|
||||
// torrent view
|
||||
myFilterModel.setSourceModel(&myModel);
|
||||
|
@ -851,6 +852,7 @@ void MainWindow::refreshActionSensitivity()
|
|||
int selectedWithMetadata(0);
|
||||
QAbstractItemModel const* model(ui.listView->model());
|
||||
QItemSelectionModel const* selectionModel(ui.listView->selectionModel());
|
||||
bool const hasSelection = selectionModel->hasSelection();
|
||||
int const rowCount(model->rowCount());
|
||||
|
||||
// count how many torrents are selected, paused, etc
|
||||
|
@ -862,8 +864,8 @@ void MainWindow::refreshActionSensitivity()
|
|||
|
||||
if (tor != nullptr)
|
||||
{
|
||||
bool const isSelected(selectionModel->isSelected(modelIndex));
|
||||
bool const isPaused(tor->isPaused());
|
||||
bool const isSelected = hasSelection && selectionModel->isSelected(modelIndex);
|
||||
bool const isPaused = tor->isPaused();
|
||||
|
||||
if (isPaused)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,6 @@ public slots:
|
|||
void setFilterbarVisible(bool);
|
||||
void setStatusbarVisible(bool);
|
||||
void setCompactView(bool);
|
||||
void refreshActionSensitivity();
|
||||
void wrongAuthentication();
|
||||
|
||||
void openSession();
|
||||
|
@ -196,8 +195,9 @@ private:
|
|||
};
|
||||
int myRefreshFields = 0;
|
||||
QTimer myRefreshTimer;
|
||||
void refreshTitle();
|
||||
void refreshTrayIcon(TransferStats const&);
|
||||
void refreshActionSensitivity();
|
||||
void refreshStatusBar(TransferStats const&);
|
||||
void refreshTitle();
|
||||
void refreshTorrentViewHeader();
|
||||
void refreshTrayIcon(TransferStats const&);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue