############################################################################## ################################# SLOTS #################################### ##############################################################################
| 383 | // ################################# SLOTS #################################### |
| 384 | // ############################################################################## |
| 385 | void ImportProjectDialog::selectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) { |
| 386 | // determine the dependent objects and select/deselect them too |
| 387 | const QModelIndexList& indexes = selected.indexes(); |
| 388 | if (indexes.isEmpty()) |
| 389 | return; |
| 390 | |
| 391 | // for the just selected aspect, determine all the objects it depends on and select them, too |
| 392 | // TODO: we need a better "selection", maybe with tri-state check boxes in the tree view |
| 393 | const auto* aspect = static_cast<const AbstractAspect*>(indexes.at(0).internalPointer()); |
| 394 | const QVector<AbstractAspect*> aspects = aspect->dependsOn(); |
| 395 | |
| 396 | const auto* model = reinterpret_cast<AspectTreeModel*>(ui.tvPreview->model()); |
| 397 | for (const auto* aspect : aspects) { |
| 398 | QModelIndex index = model->modelIndexOfAspect(aspect, 0); |
| 399 | ui.tvPreview->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); |
| 400 | } |
| 401 | |
| 402 | // Ok-button is only enabled if some project objects were selected |
| 403 | bool enable = (selected.indexes().size() != 0); |
| 404 | m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable); |
| 405 | if (enable) |
| 406 | m_buttonBox->button(QDialogButtonBox::Ok)->setToolTip(i18n("Close the dialog and import the selected objects.")); |
| 407 | else |
| 408 | m_buttonBox->button(QDialogButtonBox::Ok)->setToolTip(i18n("Select object(s) to be imported.")); |
| 409 | } |
| 410 | |
| 411 | class OPJFilterProxyModel : public QSortFilterProxyModel { |
| 412 | protected: |
nothing calls this directly
no test coverage detected