mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +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);
|
myWatchDir = new WatchDir(*myModel);
|
||||||
|
|
||||||
connect(myModel, &TorrentModel::torrentsAdded, this, &Application::onTorrentsAdded);
|
connect(myModel, &TorrentModel::torrentsAdded, this, &Application::onTorrentsAdded);
|
||||||
connect(myModel, &TorrentModel::torrentsChanged, myWindow, &MainWindow::refreshActionSensitivity);
|
|
||||||
connect(myModel, &TorrentModel::torrentsCompleted, this, &Application::onTorrentsCompleted);
|
connect(myModel, &TorrentModel::torrentsCompleted, this, &Application::onTorrentsCompleted);
|
||||||
connect(myModel, &TorrentModel::torrentsNeedInfo, this, &Application::onTorrentsNeedInfo);
|
connect(myModel, &TorrentModel::torrentsNeedInfo, this, &Application::onTorrentsNeedInfo);
|
||||||
connect(myPrefs, &Prefs::changed, this, &Application::refreshPref);
|
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); };
|
auto refreshActionSensitivitySoon = [this]() { refreshSoon(REFRESH_ACTION_SENSITIVITY); };
|
||||||
connect(&myFilterModel, &TorrentFilter::rowsInserted, this, refreshActionSensitivitySoon);
|
connect(&myFilterModel, &TorrentFilter::rowsInserted, this, refreshActionSensitivitySoon);
|
||||||
connect(&myFilterModel, &TorrentFilter::rowsRemoved, this, refreshActionSensitivitySoon);
|
connect(&myFilterModel, &TorrentFilter::rowsRemoved, this, refreshActionSensitivitySoon);
|
||||||
|
connect(&myModel, &TorrentModel::torrentsChanged, this, refreshActionSensitivitySoon);
|
||||||
|
|
||||||
// torrent view
|
// torrent view
|
||||||
myFilterModel.setSourceModel(&myModel);
|
myFilterModel.setSourceModel(&myModel);
|
||||||
|
@ -851,6 +852,7 @@ void MainWindow::refreshActionSensitivity()
|
||||||
int selectedWithMetadata(0);
|
int selectedWithMetadata(0);
|
||||||
QAbstractItemModel const* model(ui.listView->model());
|
QAbstractItemModel const* model(ui.listView->model());
|
||||||
QItemSelectionModel const* selectionModel(ui.listView->selectionModel());
|
QItemSelectionModel const* selectionModel(ui.listView->selectionModel());
|
||||||
|
bool const hasSelection = selectionModel->hasSelection();
|
||||||
int const rowCount(model->rowCount());
|
int const rowCount(model->rowCount());
|
||||||
|
|
||||||
// count how many torrents are selected, paused, etc
|
// count how many torrents are selected, paused, etc
|
||||||
|
@ -862,8 +864,8 @@ void MainWindow::refreshActionSensitivity()
|
||||||
|
|
||||||
if (tor != nullptr)
|
if (tor != nullptr)
|
||||||
{
|
{
|
||||||
bool const isSelected(selectionModel->isSelected(modelIndex));
|
bool const isSelected = hasSelection && selectionModel->isSelected(modelIndex);
|
||||||
bool const isPaused(tor->isPaused());
|
bool const isPaused = tor->isPaused();
|
||||||
|
|
||||||
if (isPaused)
|
if (isPaused)
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,7 +79,6 @@ public slots:
|
||||||
void setFilterbarVisible(bool);
|
void setFilterbarVisible(bool);
|
||||||
void setStatusbarVisible(bool);
|
void setStatusbarVisible(bool);
|
||||||
void setCompactView(bool);
|
void setCompactView(bool);
|
||||||
void refreshActionSensitivity();
|
|
||||||
void wrongAuthentication();
|
void wrongAuthentication();
|
||||||
|
|
||||||
void openSession();
|
void openSession();
|
||||||
|
@ -196,8 +195,9 @@ private:
|
||||||
};
|
};
|
||||||
int myRefreshFields = 0;
|
int myRefreshFields = 0;
|
||||||
QTimer myRefreshTimer;
|
QTimer myRefreshTimer;
|
||||||
void refreshTitle();
|
void refreshActionSensitivity();
|
||||||
void refreshTrayIcon(TransferStats const&);
|
|
||||||
void refreshStatusBar(TransferStats const&);
|
void refreshStatusBar(TransferStats const&);
|
||||||
|
void refreshTitle();
|
||||||
void refreshTorrentViewHeader();
|
void refreshTorrentViewHeader();
|
||||||
|
void refreshTrayIcon(TransferStats const&);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue