void ActionManagerPrivate::readUserSettings(Id id, Action *cmd) { QSettings *settings = ICore::settings(); settings->beginGroup(QLatin1String(kKeyboardSettingsKey)); if (settings->contains(id.toString())) cmd->setKeySequence(QKeySequence(settings->value(id.toString()).toString())); settings->endGroup(); }
void Repository::removeBackReference(const Id &id, const Id &reference) const { if (mObjects.contains(id)) { if (mObjects.contains(reference)) { mObjects[id]->removeBackReference(reference); } else { throw Exception("Repository: removing nonexistent back reference " + reference.toString() + " of object " + id.toString()); } } else { throw Exception("Repository: removing back reference of nonexistent object " + id.toString()); } }
void Client::removeParent(const Id &id, const Id &parent) { if (mObjects.contains(id)) { if (mObjects.contains(parent)) { mObjects[id]->removeParent(parent); mObjects[parent]->removeChild(id); } else { throw Exception("Client: Removing nonexistent parent " + parent.toString() + " from object " + id.toString()); } } else { throw Exception("Client: Removing parent " + parent.toString() + " from nonexistent object " + id.toString()); } }
void Repository::removeChild(const Id &id, const Id &child) { if (mObjects.contains(id)) { if (mObjects.contains(child)) { mObjects[id]->removeChild(child); } else { throw Exception("Repository: removing nonexistent child " + child.toString() + " from object " + id.toString()); } } else { throw Exception("Repository: removing child " + child.toString() + " from nonexistent object " + id.toString()); } }
void Client::addParent(Id const &id, Id const &parent) { if (mObjects.contains(id)) { if (mObjects.contains(parent)) { mObjects[id]->addParent(parent); if (!failSafe || !mObjects[parent]->children().contains(id)) mObjects[parent]->addChild(id); } else { throw Exception("Client: Adding nonexistent parent " + parent.toString() + " to object " + id.toString()); } } else { throw Exception("Client: Adding parent " + parent.toString() + " to nonexistent object " + id.toString()); } }
void Controller::diagramClosed(const Id &diagramId) { if (diagramId.isNull() || !mDiagramStacks.keys().contains(diagramId.toString())) { return; } if (mActiveStack == mDiagramStacks[diagramId.toString()]) { mActiveStack = nullptr; } delete mDiagramStacks[diagramId.toString()]; mDiagramStacks.remove(diagramId.toString()); resetAll(); }
void Repository::removeParent(const Id &id) { if (mObjects.contains(id)) { const Id parent = mObjects[id]->parent(); if (mObjects.contains(parent)) { mObjects[id]->setParent(Id()); mObjects[parent]->removeChild(id); } else { throw Exception("Repository: Removing nonexistent parent " + parent.toString() + " from object " + id.toString()); } } else { throw Exception("Repository: Removing parent from nonexistent object " + id.toString()); } }
void Repository::setParent(const Id &id, const Id &parent) { if (mObjects.contains(id)) { if (mObjects.contains(parent)) { mObjects[id]->setParent(parent); if (!mObjects[parent]->children().contains(id)) mObjects[parent]->addChild(id); } else { throw Exception("Repository: Adding nonexistent parent " + parent.toString() + " to object " + id.toString()); } } else { throw Exception("Repository: Adding parent " + parent.toString() + " to nonexistent object " + id.toString()); } }
//<有返回值函数定义部分>::= <声明头部>'('<参数>')''{'<复合语句>'}' void Parser::procDef(ifstream &file, Token tok, Type type) { int count = 0; Stmt s; Table table(lex); proc = tok.lexeme; match(LPAR, file, Error(3, lex.line)); table.global = (*(tables.get("global"))).table; tables.put(proc, table); (*tables.get(proc)).type = type; Temp::count = 0; while (look.tag == INT || look.tag == FLOAT || look.tag == CHAR) { Type p; switch (look.tag) { case INT: p = Type::_int; break; case FLOAT: p = Type::_float; break; case CHAR: p = Type::_char; break; default: break; } move(file); Token t; t = look; match(ID, file, Error(12, lex.line)); Id id = Id(Word(t.toString(), t.tag), p, used, PARA, lex.line); (*(tables.get(proc))).put(id.toString(), id); (*(tables.get(proc))).params.push_back(id.op.lexeme); (*(tables.get(proc))).paramsType.push_back(p.tag); count++; used += p.width; if (look.tag != COMMA) break; move(file); } (*(tables.get(proc))).paramsNum = count; match(RPAR, file, Error(4, lex.line)); match(LBRACE, file, Error(7, lex.line)); block(file, s); match(RBRACE, file, Error(8, lex.line)); vector<Quadruple>::iterator iter; int hasReturn; for (hasReturn = 0, iter = s.code.begin(); iter != s.code.end(); ++iter) { if ((*iter).op == "return") { hasReturn = 1; } } if (!hasReturn) { Error(20, lex.line, "\'" + proc + "\': must return a value.").print(); } (*tables.get(proc)).quad = s.code; (*tables.get(proc)).tempNum = Temp::count; Temp::count = 0; }
//<变量定义>::= <类型标识符><标识符>{,<标识符>} void Parser::varDef(ifstream &file, Token tok1, Token tok2) { Id id0; Type p; switch (tok1.tag) { case INT: p = Type::_int; break; case FLOAT: p = Type::_float; break; case CHAR: p = Type::_char; break; default: break; } id0 = Id(Word(tok2.toString(), tok2.tag), p, used, VAR, lex.line); (*(tables.get(proc))).put(id0.toString(), id0); used += p.width; while (look.tag == COMMA) { move(file); if (look.tag == ID) { Id id = Id(Word(look.toString(), look.tag), p, used, VAR, lex.line); (*(tables.get(proc))).put(id.toString(), id); used += p.width; move(file); } else Error(12, lex.line).print(); } }
JNIEXPORT jstring JNICALL Java_be_kuleuven_mech_rsg_jni_RsgJNI_getIdAsString (JNIEnv* env, jclass, jlong idPtr) { Id* id = reinterpret_cast<Id*>(idPtr); assert (id != 0); return (env)->NewStringUTF(id->toString().c_str()); }
virtual QStringList callMethod( EditorManagerInterface *editorManagerInterface , const Id &editorId , const Id &diagramId , const Id &elementId , const QString &propertyName ) const { Q_UNUSED(propertyName); mResult = callFunction([this, editorManagerInterface, editorId, diagramId, elementId]() { return callIsParent(editorManagerInterface, editorId, diagramId, elementId); }); QStringList result; for (const Id &parentDiagram : editorManagerInterface->diagrams(editorId)) { for (const Id &parentElement : editorManagerInterface->elements(diagramId)) { bool isParent = editorManagerInterface->isParentOf(elementId, parentElement); if (isParent) { result << parentElement.toString(); result << " is parent of "; result << elementId.toString(); } } } return result; }
Id Id::loadFromString(QString const &string) { Id result; result.mId = string; Q_ASSERT(string == result.toString()); return result; }
void Client::removeProperty( const Id &id, const QString &name ) { if (mObjects.contains(id)) { return mObjects[id]->removeProperty(name); } else { throw Exception("Client: Removing property of nonexistent object " + id.toString()); } }
QVariant Client::property( const Id &id, const QString &name ) const { if (mObjects.contains(id)) { return mObjects[id]->property(name); } else { throw Exception("Client: Requesting property of nonexistent object " + id.toString()); } }
IdList Repository::children(const Id &id) const { if (mObjects.contains(id)) { return mObjects[id]->children(); } else { throw Exception("Repository: Requesting children of nonexistent object " + id.toString()); } }
void Object::removeChild(const Id &child) { if (mChildren.contains(child)) { mChildren.removeAll(child); } else { throw Exception("Object " + mId.toString() + ": removing nonexistent child " + child.toString()); } }
void Object::addChild(const Id &child) { if (!mChildren.contains(child)) { mChildren.append(child); } else { throw Exception("Object " + mId.toString() + ": adding existing child " + child.toString()); } }
Id Repository::parent(const Id &id) const { if (mObjects.contains(id)) { return mObjects[id]->parent(); } else { throw Exception("Repository: Requesting parents of nonexistent object " + id.toString()); } }
QString ProxyEditorManager::addNodeElement(Id const &diagram, QString const &name, bool isRootDiagramNode) { QString res = mProxiedEditorManager->addNodeElement(diagram, name, isRootDiagramNode); QStringList params; params << "addNode" << diagram.toString() << name << (isRootDiagramNode ? "t" : "f") << res; emit metaModelChanged(params.join("|") + "|"); return res; }
IdList Client::parents(Id const &id) const { if (mObjects.contains(id)) { return mObjects[id]->parents(); } else { throw Exception("Client: Requesting parents of nonexistent object " + id.toString()); } }
bool frts::IdImpl::operator==(const Id& rhs) { #ifdef FRTS_FAST_ID return this == &rhs; #else return str == rhs.toString(); #endif }
QString ProxyEditorManager::addEdgeElement(Id const &diagram, QString const &name, QString const &labelText , QString const &labelType, QString const &lineType, QString const &beginType, QString const &endType) { QString res = mProxiedEditorManager->addEdgeElement(diagram, name, labelText, labelType, lineType, beginType, endType); QStringList params; params << "addEdge" << diagram.toString() << name << labelText << labelType << lineType << beginType << endType << res; emit metaModelChanged(params.join("|") + "|"); return res; }
void Controller::setActiveDiagram(const Id &diagramId) { if (diagramId != Id()) { setActiveStack(mDiagramStacks[diagramId.toString()]); } else { setActiveStack(nullptr); } resetAll(); }
//<无返回值函数定义部分>::= void<标识符>'('<参数>')''{'<复合语句>'}' void Parser::voidProcDef(ifstream &file) { int count = 0; Stmt s; Table table(lex); proc = look.lexeme; move(file); match(LPAR, file, Error(3, lex.line)); table.global = (*(tables.get("global"))).table; tables.put(proc, table); (*tables.get(proc)).type = Type::_null; Temp::count = 0; while (look.tag == INT || look.tag == FLOAT || look.tag == CHAR) { Type p; switch (look.tag) { case INT: p = Type::_int; break; case FLOAT: p = Type::_float; break; case CHAR: p = Type::_char; break; default: break; } move(file); Token t; t = look; match(ID, file, Error(12, lex.line)); Id id = Id(Word(t.toString(), t.tag), p, used, PARA, lex.line); (*(tables.get(proc))).put(id.toString(), id); (*(tables.get(proc))).params.push_back(id.op.lexeme); (*(tables.get(proc))).paramsType.push_back(p.tag); count++; used += p.width; if (look.tag != COMMA) break; move(file); } (*tables.get(proc)).paramsNum = count; match(RPAR, file, Error(4, lex.line)); match(LBRACE, file, Error(7, lex.line)); block(file, s); match(RBRACE, file, Error(8, lex.line)); /*vector<Quadruple>::iterator iter; for (iter = s.code.begin(); iter != s.code.end(); ++iter) { if ((*iter).op == "return" && (*iter).expr1 != "") { Error(21, lex.line, "\'" + proc + "\': \'void\' function returning a value."); break; } }*/ (*tables.get(proc)).quad.insert((*tables.get(proc)).quad.end(), s.code.begin(), s.code.end()); (*tables.get(proc)).tempNum = Temp::count; Temp::count = 0; }
bool Repository::hasProperty(const Id &id, const QString &name, bool sensitivity, bool regExpression) const { if (mObjects.contains(id)) { return mObjects[id]->hasProperty(name, sensitivity, regExpression); } else { throw Exception("Repository: Checking the existence of a property '" + name + "' of nonexistent object " + id.toString()); } }
void Controller::diagramOpened(const Id &diagramId) { if (diagramId.isNull()) { return; } UndoStack *stack = new UndoStack; connectStack(stack); mDiagramStacks.insert(diagramId.toString(), stack); resetAll(); }
TEST(IdsTest, toUrlToStringToVariantTest) { QString const idString = "qrm:/editor/diagram/element/id"; Id const id = Id::loadFromString(idString); EXPECT_EQ(id.toString(), idString); EXPECT_EQ(id.toUrl(), QUrl(idString)); QVariant toVariant = id.toVariant(); EXPECT_EQ(toVariant.value<Id>(), id); }
void Client::setProperty(const Id &id, const QString &name, const QVariant &value ) { if (mObjects.contains(id)) { Q_ASSERT(mObjects[id]->hasProperty(name) ? mObjects[id]->property(name).userType() == value.userType() : true); mObjects[id]->setProperty(name, value); } else { throw Exception("Client: Setting property of nonexistent object " + id.toString()); } }
static QString msgActionWarning(QAction *newAction, Id id, QAction *oldAction) { QString msg; QTextStream str(&msg); str << "addOverrideAction " << newAction->objectName() << '/' << newAction->text() << ": Action "; if (oldAction) str << oldAction->objectName() << '/' << oldAction->text(); str << " is already registered for context " << id.uniqueIdentifier() << ' ' << id.toString() << '.'; return msg; }