| 408 | } |
| 409 | |
| 410 | void ProblemsView::addModel(const ModelData& newData) |
| 411 | { |
| 412 | // We implement follows tabs order: |
| 413 | // |
| 414 | // 1) First tab always used by "Parser" model due to it's the most important |
| 415 | // problem listing, it should be at the front (K.Funk idea at #kdevelop IRC channel). |
| 416 | // |
| 417 | // 2) Other tabs are alphabetically ordered. |
| 418 | |
| 419 | const QString parserId = QStringLiteral("Parser"); |
| 420 | |
| 421 | auto model = newData.model; |
| 422 | auto view = new ProblemTreeView(nullptr, model); |
| 423 | connect(view, &ProblemTreeView::changed, this, &ProblemsView::onViewChanged); |
| 424 | connect(model, &ProblemModel::fullUpdateTooltipChanged, |
| 425 | this, [this, model]() { |
| 426 | if (currentView()->model() == model) { |
| 427 | m_fullUpdateAction->setToolTip(model->fullUpdateTooltip()); |
| 428 | } |
| 429 | }); |
| 430 | |
| 431 | int insertIdx = 0; |
| 432 | if (newData.id != parserId) { |
| 433 | for (insertIdx = 0; insertIdx < m_models.size(); ++insertIdx) { |
| 434 | const ModelData& currentData = m_models[insertIdx]; |
| 435 | |
| 436 | // Skip first element if it's already occupied by "Parser" model |
| 437 | if (insertIdx == 0 && currentData.id == parserId) |
| 438 | continue; |
| 439 | |
| 440 | if (currentData.name.localeAwareCompare(newData.name) > 0) |
| 441 | break; |
| 442 | } |
| 443 | } |
| 444 | m_tabWidget->insertTab(insertIdx, view, newData.name); |
| 445 | m_models.insert(insertIdx, newData); |
| 446 | |
| 447 | updateTab(insertIdx, model->rowCount()); |
| 448 | } |
| 449 | |
| 450 | void ProblemsView::updateTab(int idx, int rows) |
| 451 | { |