| 78 | } |
| 79 | |
| 80 | void SessionChooserDialog::updateState() { |
| 81 | // Sometimes locking may take some time, so we stop the timer, to prevent an 'avalanche' of events |
| 82 | m_updateStateTimer.stop(); |
| 83 | for(int row = 0; row < m_model->rowCount(); ++row) |
| 84 | { |
| 85 | QString session = m_model->index(row, 0).data().toString(); |
| 86 | |
| 87 | if(session.isEmpty()) //create new session |
| 88 | continue; |
| 89 | |
| 90 | QString state, tooltip; |
| 91 | SessionRunInfo info = SessionController::sessionRunInfo(session); |
| 92 | if(info.isRunning) |
| 93 | { |
| 94 | tooltip = i18nc("@info:tooltip", "Active session.\npid %1, app %2, host %3", |
| 95 | info.holderPid, info.holderApp, info.holderHostname); |
| 96 | state = i18n("Running"); |
| 97 | } |
| 98 | |
| 99 | m_model->setData(m_model->index(row, 1), |
| 100 | !info.isRunning ? QIcon() : QIcon::fromTheme(QStringLiteral("media-playback-start")), |
| 101 | Qt::DecorationRole); |
| 102 | m_model->setData(m_model->index(row, 1), tooltip, Qt::ToolTipRole); |
| 103 | m_model->setData(m_model->index(row, 2), state, Qt::DisplayRole); |
| 104 | } |
| 105 | |
| 106 | m_updateStateTimer.start(); |
| 107 | } |
| 108 | |
| 109 | void SessionChooserDialog::itemEntered(const QModelIndex& index) |
| 110 | { |