| 178 | } |
| 179 | |
| 180 | void ProjectTree::removeRootItem(QStandardItem *root) |
| 181 | { |
| 182 | this->viewport()->setUpdatesEnabled(false); |
| 183 | |
| 184 | ProjectInfo info = ProjectInfo::get(ProjectGenerator::root(root)); |
| 185 | |
| 186 | // 从Model中移除 |
| 187 | this->takeRootItem(root); |
| 188 | |
| 189 | // 从生成器中删除 |
| 190 | using namespace dpfservice; |
| 191 | auto &ctx = dpfInstance.serviceContext(); |
| 192 | ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name()); |
| 193 | if (!projectService) |
| 194 | return; |
| 195 | |
| 196 | auto generator = projectService->createGenerator<ProjectGenerator>(info.kitName()); |
| 197 | if (generator) |
| 198 | generator->removeRootItem(root); |
| 199 | |
| 200 | // 发送工程删除信号 |
| 201 | SendEvents::projectDeleted(info); |
| 202 | |
| 203 | // 始终保持首选项 |
| 204 | int rowCount = d->itemModel->rowCount(); |
| 205 | if (0 < rowCount) { // 存在其他工程时 |
| 206 | auto index = d->itemModel->index(0, 0); |
| 207 | doActiveProject(d->itemModel->itemFromIndex(index)); |
| 208 | } |
| 209 | |
| 210 | this->viewport()->setUpdatesEnabled(true); |
| 211 | } |
| 212 | |
| 213 | void ProjectTree::takeRootItem(QStandardItem *root) |
| 214 | { |
no test coverage detected