| 139 | } |
| 140 | |
| 141 | void WorksheetPreviewWidget::aspectAdded(const AbstractAspect* aspect) { |
| 142 | if (m_project->isLoading()) |
| 143 | return; |
| 144 | |
| 145 | const auto* w = dynamic_cast<const Worksheet*>(aspect); |
| 146 | if (w) { |
| 147 | addPreview(w, indexOfWorksheet(w)); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | // in case a folder was added (copy&paste, duplicate, project import), check whether it has worksheets |
| 152 | // and add previews for them |
| 153 | const auto* folder = dynamic_cast<const Folder*>(aspect); |
| 154 | if (folder) { |
| 155 | QTimer::singleShot(0, this, [=]() { |
| 156 | const auto& worksheets = folder->children<Worksheet>(AbstractAspect::ChildIndexFlag::Recursive); |
| 157 | for (const auto* w : worksheets) |
| 158 | addPreview(w, indexOfWorksheet(w)); |
| 159 | }); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | void WorksheetPreviewWidget::aspectSelected(const AbstractAspect* aspect) { |
| 164 | if (!m_project) |