void QuickEdit::AddParameter() { QModelIndex current = ui->tvEditor->selectionModel()->currentIndex(); if (!current.isValid()) return; current = current.sibling(current.row(), 0); TreeItemInterface* itemAsInterface = static_cast<TreeItemInterface*>(current.internalPointer()); BrowserNode* currentNode = static_cast<BrowserNode*>(itemAsInterface->InternalPointer()); BrowserOperation* operationNode; if (currentNode->TypeID() == TypeIdentifier<BrowserOperation>::id()) { operationNode = static_cast<BrowserOperation*>(currentNode); } else if (currentNode->TypeID() == TypeIdentifier<BrowserOperationAttribute>::id()) { operationNode = static_cast<BrowserOperationAttribute*>(currentNode)->get_operation(); itemAsInterface = itemAsInterface->parent(); current = current.parent(); } else return; OperationData* currentData = static_cast<OperationData*>(operationNode->get_data()); int originalParamCount = currentData->nparams; currentData->set_n_params(originalParamCount + 1); QModelIndex parentIndex = current.parent(); parentIndex = parentIndex.sibling(parentIndex.row(), 0); TreeItemInterface* parent = static_cast<TreeItemInterface*>(parentIndex.internalPointer()); if (!parent) parent = treeModel->RootItem(); int insertIndex = parent->GetIndexOfChild(itemAsInterface); auto sharedOfOperation = parent->GetChildren()[insertIndex]; int newItemPosition = currentData->nparams; if (!treeModel->insertRows(sharedOfOperation->childCount(), 1, current)) return; QSharedPointer<BrowserNode> param(new BrowserOperationAttribute(dummyView, static_cast<BrowserOperation*>(operationNode), currentData->params.last())); localNodeHolder.push_back(param); if (!current.isValid()) return; QModelIndex newItem = treeModel->index(sharedOfOperation->childCount() - 1, 0, current); TreeItemInterface *newItemInterface = static_cast<TreeItemInterface*>(newItem.internalPointer()); TreeItem<BrowserNode>* newItemAsNode = static_cast<TreeItem<BrowserNode>*>(newItemInterface); newItemAsNode->SetController(operationAttributeController); newItemAsNode->SetParent(sharedOfOperation); newItemAsNode->SetInternalData(param.data()); operationNode->modified(); OperationFuncs::recompute_param(operationNode, newItemPosition - 1, true); }
BrowserOperation * BrowserOperation::new_one(QString s, BrowserNode * p) { OperationData * d = new OperationData(); BrowserOperation * result = new BrowserOperation(s, p, d, d->get_ident()); d->set_browser_node(result, TRUE); return result; }
void CodAddMsgDialog::menu_op() { QPopupMenu m(0); m.insertItem(TR("Choose"), -1); m.insertSeparator(); int index = list.findIndex(edoper->currentText().stripWhiteSpace()); if (index != -1) m.insertItem(TR("Select in browser"), 0); BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp() && (opers.findIndex((OperationData *) bn->get_data()) != -1)) m.insertItem(TR("Choose operation selected in browser"), 1); else bn = 0; if (cl != 0) m.insertItem(TR("Create operation and choose it"), 2); if ((index != -1) || (bn != 0) || (cl != 0)) { switch (m.exec(QCursor::pos())) { case 0: opers[index]->get_browser_node()->select_in_browser(); break; case 2: bn = cl->add_operation(); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { OperationData * od = (OperationData *) bn->get_data(); if ((index = opers.findIndex(od)) == -1) { index = opers.count(); opers.append(od); QString s = od->definition(TRUE, FALSE); list.append(s); edoper->insertItem(s); } } edoper->setCurrentItem(index + 1); } } }
BrowserOperation * BrowserOperation::new_one(QString s, BrowserNode * p) { OperationData * d = new OperationData(); BrowserOperation * result = new BrowserOperation(s, p, d, d->get_ident()); d->set_browser_node(result, TRUE); QString nameOfClassNode = p->get_name(); //if constructor int lastIndexOfConstructor = 0; //leave members other then operations and attributes in place while(BrowserNode *node = (BrowserNode *)p->child(lastIndexOfConstructor)) { if(UmlOperation != node->get_type() && UmlAttribute != node->get_type()) { lastIndexOfConstructor++; } else break; } while(BrowserNode *node = (BrowserNode *)p->child(lastIndexOfConstructor)) { if(nameOfClassNode == node->get_name()) { lastIndexOfConstructor++; } else break; } if(nameOfClassNode == s) { p->removeChild(result); p->insertChild(lastIndexOfConstructor,result); } //destructor else if(("~" + nameOfClassNode) == s) { p->removeChild(result); p->insertChild(lastIndexOfConstructor,result); } return result; }
/** * grl_operation_cancel: * @operation_id: the identifier of a running operation * * Cancel an operation. */ void grl_operation_cancel (guint operation_id) { OperationData *data = g_hash_table_lookup (operations, GUINT_TO_POINTER (operation_id)); if (!data) { GRL_WARNING ("Invalid operation %u", operation_id); return; } g_return_if_fail (data != NULL); if (data->cancel_cb) { data->cancel_cb (data->private_data); } }
void CodChangeMsgDialog::menu_op() { QMenu m(0); MenuFactory::addItem(m, tr("Choose"), -1); m.addSeparator(); int index = list.indexOf(edoper->currentText().trimmed()); if (index != -1) MenuFactory::addItem(m, tr("Select in browser"), 0); BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp() && (opers.indexOf((OperationData *) bn->get_data()) != -1)) MenuFactory::addItem(m, tr("Choose operation selected in browser"), 1); else bn = 0; if (cl != 0) MenuFactory::addItem(m, tr("Create operation and choose it"), 2); if ((index != -1) || (bn != 0) || (cl != 0)) { QAction* retAction = m.exec(QCursor::pos()); if(retAction) { switch (retAction->data().toInt()) { case 0: opers[index]->get_browser_node()->select_in_browser(); break; case 2: bn = cl->add_operation(); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { OperationData * od = (OperationData *) bn->get_data(); if ((index = opers.indexOf(od)) == -1) { index = opers.count(); opers.append(od); QString s = od->definition(TRUE, FALSE); list.append(s); edoper->addItem(s); } } edoper->setCurrentIndex(index + 1); } } } }