| 462 | } |
| 463 | |
| 464 | void Container::addWidget(View* view, QWidget* widget, int position) |
| 465 | { |
| 466 | Q_D(Container); |
| 467 | |
| 468 | Q_ASSERT(view); |
| 469 | Q_ASSERT(widget); |
| 470 | Q_ASSERT(widget == view->widget()); |
| 471 | Q_ASSERT(!hasWidget(widget)); |
| 472 | |
| 473 | int idx = 0; |
| 474 | if (position != -1) |
| 475 | { |
| 476 | idx = d->stack->insertWidget(position, widget); |
| 477 | } |
| 478 | else |
| 479 | idx = d->stack->addWidget(widget); |
| 480 | d->tabBar->insertTab(idx, view->document()->statusIcon(), view->document()->title()); |
| 481 | Q_ASSERT(view); |
| 482 | d->viewForWidget[widget] = view; |
| 483 | |
| 484 | // Update document list context menu. This has to be called before |
| 485 | // setCurrentWidget, because we call the status icon and title update slots |
| 486 | // from there, which in turn require view to be present in the document list menu. |
| 487 | d->insertIntoDocumentListMenu(view); |
| 488 | |
| 489 | setCurrentWidget(d->stack->currentWidget()); |
| 490 | |
| 491 | // This fixes a strange layouting bug, that could be reproduced like this: Open a few files in KDevelop, activate the rightmost tab. |
| 492 | // Then temporarily switch to another area, and then switch back. After that, the tab-bar was gone. |
| 493 | // The problem could only be fixed by closing/opening another view. |
| 494 | d->tabBar->setMinimumHeight(d->tabBar->sizeHint().height()); |
| 495 | |
| 496 | connect(view, &View::statusChanged, this, &Container::statusChanged); |
| 497 | connect(view->document(), &Document::statusIconChanged, this, &Container::statusIconChanged); |
| 498 | connect(view->document(), &Document::titleChanged, this, &Container::documentTitleChanged); |
| 499 | } |
| 500 | |
| 501 | void Container::statusChanged(Sublime::View* view) |
| 502 | { |