MCPcopy Create free account
hub / github.com/KDE/kdevelop / selectNewToolViewToAdd

Method selectNewToolViewToAdd

kdevplatform/shell/uicontroller.cpp:492–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void UiController::selectNewToolViewToAdd(MainWindow *mw)
493{
494 Q_D(UiController);
495
496 if (!mw || !mw->area())
497 return;
498
499 ScopedDialog<QDialog> dia(mw);
500 dia->setWindowTitle(i18nc("@title:window", "Select Tool View to Add"));
501
502 auto mainLayout = new QVBoxLayout(dia);
503
504 auto *list = new NewToolViewListWidget(mw, dia);
505
506 list->setSelectionMode(QAbstractItemView::ExtendedSelection);
507 list->setSortingEnabled(true);
508 for (QHash<IToolViewFactory*, Sublime::ToolDocument*>::const_iterator it = d->factoryDocuments.constBegin();
509 it != d->factoryDocuments.constEnd(); ++it)
510 {
511 auto* item = new ViewSelectorItem(it.value()->title(), it.key(), list);
512 if (toolViewPresent(it.value(), mw->area())) {
513 // Disable item if the tool view is already present.
514 item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
515 }
516 list->addItem(item);
517 }
518
519 list->setFocus();
520 connect(list, &NewToolViewListWidget::addNewToolView, this, &UiController::addNewToolView);
521 mainLayout->addWidget(list);
522
523 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
524 auto okButton = buttonBox->button(QDialogButtonBox::Ok);
525 okButton->setDefault(true);
526 okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
527 dia->connect(buttonBox, &QDialogButtonBox::accepted, dia.data(), &QDialog::accept);
528 dia->connect(buttonBox, &QDialogButtonBox::rejected, dia.data(), &QDialog::reject);
529 mainLayout->addWidget(buttonBox);
530
531 if (dia->exec() == QDialog::Accepted)
532 {
533 const auto items = list->selectedItems();
534 for (QListWidgetItem* item : items) {
535 addNewToolView(mw, item);
536 }
537 }
538}
539
540void UiController::addNewToolView(MainWindow *mw, QListWidgetItem* item)
541{

Callers 1

viewAddNewToolViewMethod · 0.80

Calls 15

setSortingEnabledMethod · 0.80
constBeginMethod · 0.80
constEndMethod · 0.80
setFlagsMethod · 0.80
buttonMethod · 0.80
execMethod · 0.80
selectedItemsMethod · 0.80
areaMethod · 0.45
titleMethod · 0.45
valueMethod · 0.45
keyMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected