| 172 | |
| 173 | |
| 174 | void SidepanelEditor::onContextMenu(const QPoint& pos) |
| 175 | { |
| 176 | QTreeWidgetItem* selected_item = ui->paletteTreeWidget->itemAt(pos); |
| 177 | if( selected_item == nullptr) |
| 178 | { |
| 179 | return; |
| 180 | } |
| 181 | QString selected_name = selected_item->text(0); |
| 182 | |
| 183 | if( ui->buttonLock->isChecked() || |
| 184 | BuiltinNodeModels().count( selected_name ) != 0 ) |
| 185 | { |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | QMenu menu(this); |
| 190 | |
| 191 | QAction* edit = menu.addAction("Edit"); |
| 192 | connect( edit, &QAction::triggered, this, [this, selected_name]() |
| 193 | { |
| 194 | CustomNodeDialog dialog(_tree_nodes_model, selected_name, this); |
| 195 | if( dialog.exec() == QDialog::Accepted) |
| 196 | { |
| 197 | onReplaceModel( selected_name, dialog.getTreeNodeModel() ); |
| 198 | } |
| 199 | } ); |
| 200 | |
| 201 | QAction* remove = menu.addAction("Remove"); |
| 202 | |
| 203 | connect( remove, &QAction::triggered, this,[this, selected_name]() |
| 204 | { |
| 205 | emit modelRemoveRequested(selected_name); |
| 206 | } ); |
| 207 | |
| 208 | QPoint globalPos = ui->paletteTreeWidget->mapToGlobal(pos); |
| 209 | menu.exec(globalPos); |
| 210 | |
| 211 | QApplication::processEvents(); |
| 212 | } |
| 213 | |
| 214 | void SidepanelEditor::onReplaceModel(const QString& old_name, |
| 215 | const NodeModel &new_model) |
nothing calls this directly
no test coverage detected