| 101 | }; |
| 102 | |
| 103 | ProcessSelectionDialog::ProcessSelectionDialog(QWidget* parent) |
| 104 | : QDialog(parent) |
| 105 | { |
| 106 | m_ui.setupUi(this); |
| 107 | |
| 108 | auto* const view = m_ui.view; |
| 109 | |
| 110 | const QStringList attributes = {QStringLiteral("name"), QStringLiteral("pid"), QStringLiteral("username"), |
| 111 | QStringLiteral("startTime"), QStringLiteral("command"), QStringLiteral("euid")}; |
| 112 | |
| 113 | m_dataModel = new KSysGuard::ProcessDataModel(this); |
| 114 | m_dataModel->setEnabledAttributes(attributes); |
| 115 | |
| 116 | m_sortModel = new ProcessesSortFilterModel(attributes.indexOf(QStringLiteral("euid")), this); |
| 117 | m_sortModel->setSourceModel(m_dataModel); |
| 118 | |
| 119 | view->setModel(m_sortModel); |
| 120 | |
| 121 | m_pidColumn = attributes.indexOf(QStringLiteral("pid")); |
| 122 | |
| 123 | connect(m_ui.filterEdit, &QLineEdit::textChanged, this, [this](const QString& text) { |
| 124 | m_sortModel->setFilterFixedString(text); |
| 125 | }); |
| 126 | |
| 127 | connect(m_ui.processesCombo, &QComboBox::activated, this, &ProcessSelectionDialog::onProcessesComboActivated); |
| 128 | |
| 129 | connect(view->selectionModel(), &QItemSelectionModel::selectionChanged, this, |
| 130 | &ProcessSelectionDialog::selectionChanged); |
| 131 | |
| 132 | connect(m_ui.buttonList, &QToolButton::toggled, this, [this](bool checked) { |
| 133 | m_ui.buttonTree->setChecked(!checked); |
| 134 | }); |
| 135 | |
| 136 | connect(m_ui.buttonTree, &QToolButton::toggled, this, [this](bool checked) { |
| 137 | m_ui.view->clearSelection(); |
| 138 | m_dataModel->setFlatList(!checked); |
| 139 | m_ui.buttonList->setChecked(!checked); |
| 140 | m_ui.view->expandAll(); |
| 141 | }); |
| 142 | |
| 143 | auto* const buttonBox = m_ui.buttonBox; |
| 144 | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 145 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 146 | m_attachButton = buttonBox->button(QDialogButtonBox::Ok); |
| 147 | m_attachButton->setDefault(true); |
| 148 | m_attachButton->setText(i18nc("@action:button", "Attach")); |
| 149 | m_attachButton->setShortcut(Qt::CTRL | Qt::Key_Return); |
| 150 | m_attachButton->setEnabled(false); |
| 151 | |
| 152 | const KConfigGroup config = KSharedConfig::openConfig()->group(QStringLiteral("ProcessSelectionDialog")); |
| 153 | m_ui.filterEdit->setText(config.readEntry("filterText", QString())); |
| 154 | |
| 155 | restoreGeometry(config.readEntry("dialogGeometry", QByteArray{})); |
| 156 | |
| 157 | m_ui.processesCombo->setCurrentIndex(config.readEntry("processOwner", 0)); |
| 158 | onProcessesComboActivated(m_ui.processesCombo->currentIndex()); |
| 159 | |
| 160 | const auto headerState = config.readEntry("headerState", QByteArray{}); |
nothing calls this directly
no test coverage detected