| 173 | } |
| 174 | |
| 175 | const TimerIdInfo *TimerModel::findTimerInfo(const QModelIndex &index) const |
| 176 | { |
| 177 | if (index.row() < m_sourceModel->rowCount()) { |
| 178 | const QModelIndex sourceIndex = m_sourceModel->index(index.row(), 0); |
| 179 | QObject *const timerObject = sourceIndex.data(ObjectModel::ObjectRole).value<QObject *>(); |
| 180 | |
| 181 | // The object might have already be deleted even if our index is valid |
| 182 | if (!timerObject) |
| 183 | return nullptr; |
| 184 | |
| 185 | const TimerId id = TimerId(timerObject); |
| 186 | auto it = m_timersInfo.find(id); |
| 187 | |
| 188 | if (it == m_timersInfo.end()) { |
| 189 | it = m_timersInfo.insert(id, TimerIdInfo()); |
| 190 | // safe, as timerObject has been validated by the source model |
| 191 | it.value().update(id); |
| 192 | } |
| 193 | |
| 194 | return &it.value(); |
| 195 | } |
| 196 | if (index.row() < m_sourceModel->rowCount() + m_freeTimersInfo.size()) { |
| 197 | return &m_freeTimersInfo[index.row() - m_sourceModel->rowCount()]; |
| 198 | } |
| 199 | |
| 200 | return nullptr; |
| 201 | } |
| 202 | |
| 203 | bool TimerModel::canHandleCaller(QObject *caller, int methodIndex) const |
| 204 | { |