* @brief Wires the basic ProjectModel rebuild signals into the tree-rebuild scheduler. */
| 279 | * @brief Wires the basic ProjectModel rebuild signals into the tree-rebuild scheduler. |
| 280 | */ |
| 281 | void DataModel::ProjectEditor::wireProjectModelRebuilds() |
| 282 | { |
| 283 | auto& pm = DataModel::ProjectModel::instance(); |
| 284 | |
| 285 | connect(&pm, |
| 286 | &DataModel::ProjectModel::groupsChanged, |
| 287 | this, |
| 288 | &DataModel::ProjectEditor::scheduleTreeRebuild, |
| 289 | Qt::QueuedConnection); |
| 290 | connect(&pm, |
| 291 | &DataModel::ProjectModel::groupsChanged, |
| 292 | this, |
| 293 | &DataModel::ProjectEditor::editableOptionsChanged, |
| 294 | Qt::QueuedConnection); |
| 295 | connect(&pm, |
| 296 | &DataModel::ProjectModel::actionsChanged, |
| 297 | this, |
| 298 | &DataModel::ProjectEditor::scheduleTreeRebuild, |
| 299 | Qt::QueuedConnection); |
| 300 | connect(&pm, |
| 301 | &DataModel::ProjectModel::tablesChanged, |
| 302 | this, |
| 303 | &DataModel::ProjectEditor::scheduleTreeRebuild, |
| 304 | Qt::QueuedConnection); |
| 305 | connect(&pm, |
| 306 | &DataModel::ProjectModel::editorWorkspacesChanged, |
| 307 | this, |
| 308 | &DataModel::ProjectEditor::scheduleTreeRebuild, |
| 309 | Qt::QueuedConnection); |
| 310 | connect( |
| 311 | &pm, |
| 312 | &DataModel::ProjectModel::sourcesChanged, |
| 313 | this, |
| 314 | [this] { |
| 315 | scheduleTreeRebuild(); |
| 316 | |
| 317 | if (m_currentView == GroupView) |
| 318 | buildGroupModel(m_selectedGroup); |
| 319 | else if (m_currentView == DatasetView) |
| 320 | buildDatasetModel(m_selectedDataset); |
| 321 | }, |
| 322 | Qt::QueuedConnection); |
| 323 | connect(&pm, &DataModel::ProjectModel::modifiedChanged, this, [this] { |
| 324 | if (m_currentView != ProjectView || !m_projectModel) |
| 325 | return; |
| 326 | |
| 327 | const auto title = DataModel::ProjectModel::instance().title(); |
| 328 | for (int i = 0; i < m_projectModel->rowCount(); ++i) { |
| 329 | auto* row = m_projectModel->item(i); |
| 330 | if (!row || row->data(ParameterType).toInt() != kProjectView_Title) |
| 331 | continue; |
| 332 | |
| 333 | if (row->data(EditableValue).toString() != title) |
| 334 | buildProjectModel(); |
| 335 | |
| 336 | return; |
| 337 | } |
| 338 |