| 134 | } |
| 135 | |
| 136 | void ScratchpadView::setupActions() |
| 137 | { |
| 138 | auto* action = new QAction(QIcon::fromTheme(QStringLiteral("list-add")), i18nc("@action", "New Scratch"), this); |
| 139 | connect(action, &QAction::triggered, this, &ScratchpadView::createScratch); |
| 140 | addAction(action); |
| 141 | |
| 142 | action = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@action", "Remove Scratch"), this); |
| 143 | connect(action, &QAction::triggered, this, [this] { |
| 144 | const QPointer thisGuard(this); |
| 145 | m_scratchpad->removeScratch(proxyModel()->mapToSource(currentIndex())); |
| 146 | if (thisGuard) { |
| 147 | validateItemActions(); |
| 148 | } // else: already destroyed (KDevelop is probably exiting now) |
| 149 | }); |
| 150 | addAction(action); |
| 151 | m_itemActions.push_back(action); |
| 152 | |
| 153 | action = new QAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18nc("@action", "Rename Scratch"), this); |
| 154 | connect(action, &QAction::triggered, this, [this] { |
| 155 | scratchView->edit(scratchView->currentIndex()); |
| 156 | }); |
| 157 | addAction(action); |
| 158 | m_itemActions.push_back(action); |
| 159 | |
| 160 | action = m_scratchpad->runAction(); |
| 161 | action->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); |
| 162 | action->setText(i18nc("@action", "Run Scratch")); |
| 163 | connect(action, &QAction::triggered, this, &ScratchpadView::runSelectedScratch); |
| 164 | addAction(action); |
| 165 | m_itemActions.push_back(action); |
| 166 | |
| 167 | m_filter = new QLineEdit(this); |
| 168 | m_filter->setPlaceholderText(i18nc("@info:placeholder", "Filter...")); |
| 169 | auto filterAction = new QWidgetAction(this); |
| 170 | filterAction->setDefaultWidget(m_filter); |
| 171 | addAction(filterAction); |
| 172 | } |
| 173 | |
| 174 | void ScratchpadView::validateItemActions() |
| 175 | { |
nothing calls this directly
no test coverage detected