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

Method showSessionChooserDialog

kdevplatform/shell/sessioncontroller.cpp:579–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579QString SessionController::showSessionChooserDialog(const QString& headerText, bool onlyRunning)
580{
581 ///FIXME: move this code into sessiondialog.cpp
582 auto* view = new QListView;
583 auto* filter = new QLineEdit;
584 filter->setClearButtonEnabled( true );
585 filter->setPlaceholderText(i18nc("@info:placeholder", "Search..."));
586
587 auto* model = new QStandardItemModel(view);
588
589 auto *proxy = new QSortFilterProxyModel(model);
590 proxy->setSourceModel(model);
591 proxy->setFilterKeyColumn( 1 );
592 proxy->setFilterCaseSensitivity( Qt::CaseInsensitive );
593 connect(filter, &QLineEdit::textChanged, proxy, &QSortFilterProxyModel::setFilterFixedString);
594
595 SessionChooserDialog dialog(view, proxy, filter);
596 view->setEditTriggers(QAbstractItemView::NoEditTriggers);
597
598 QVBoxLayout layout(dialog.mainWidget());
599 if(!headerText.isEmpty()) {
600 auto* heading = new QLabel(headerText);
601 QFont font = heading->font();
602 font.setBold(true);
603 heading->setFont(font);
604 layout.addWidget(heading);
605 }
606
607 model->setColumnCount(4);
608 model->setHeaderData(0, Qt::Horizontal,i18nc("@title:column", "Identity"));
609 model->setHeaderData(1, Qt::Horizontal,i18nc("@title:column", "Contents"));
610 model->setHeaderData(2, Qt::Horizontal,i18nc("@title:column", "State"));
611 model->setHeaderData(3, Qt::Horizontal,i18nc("@title:column", "Name"));
612
613 view->setModel(proxy);
614 view->setModelColumn(1);
615
616 auto* filterLayout = new QHBoxLayout();
617 filterLayout->addWidget(new QLabel(i18nc("@label:textbox", "Filter:")));
618 filterLayout->addWidget(filter);
619 layout.addLayout(filterLayout);
620 layout.addWidget(view);
621 filter->setFocus();
622
623 int row = 0;
624
625 QString defaultSession = KSharedConfig::openConfig()->group( cfgSessionGroup() ).readEntry( cfgActiveSessionEntry(), "default" );
626
627 const auto availableSessionInfos = KDevelop::SessionController::availableSessionInfos();
628 for (const KDevelop::SessionInfo& si : availableSessionInfos) {
629 if ( si.name.isEmpty() && si.projects.isEmpty() ) {
630 continue;
631 }
632
633 bool running = KDevelop::SessionController::isSessionRunning(si.uuid.toString());
634
635 if(onlyRunning && !running)
636 continue;

Callers

nothing calls this directly

Calls 15

setPlaceholderTextMethod · 0.80
setSourceModelMethod · 0.80
mainWidgetMethod · 0.80
readEntryMethod · 0.80
setItemMethod · 0.80
setCurrentIndexMethod · 0.80
execMethod · 0.80
siblingMethod · 0.80
QStringClass · 0.70
isEmptyMethod · 0.45
addWidgetMethod · 0.45
setModelMethod · 0.45

Tested by

no test coverage detected