本文整理汇总了C++中IdList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ IdList::count方法的具体用法?C++ IdList::count怎么用?C++ IdList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdList
的用法示例。
在下文中一共展示了IdList::count方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initNextBlocks
bool Block::initNextBlocks()
{
if (id().isNull() || id() == Id::rootId()) {
error(tr("Control flow break detected, stopping"));
return false;
}
const IdList links = mGraphicalModelApi->graphicalRepoApi().outgoingLinks(id());
if (links.count() > 1) {
error(tr("Too many outgoing links"));
return false;
}
if (links.count() == 0) {
error(tr("No outgoing links, please connect this block to something or use Final Node to end program"));
return false;
}
if (links.count() == 1) {
const Id nextBlockId = mGraphicalModelApi->graphicalRepoApi().otherEntityFromLink(links[0], id());
if (nextBlockId.isNull() || nextBlockId == Id::rootId()) {
error(tr("Outgoing link is not connected"));
return false;
}
mNextBlockId = nextBlockId;
}
return true;
}
示例2: removeOne
void CreateRemoveCommandImplementation::removeOne(ElementInfo &element)
{
if (element.id() == element.logicalId()) {
mLogicalApi.removeReferencesTo(element.id());
mLogicalApi.removeReferencesFrom(element.id());
mLogicalApi.removeElement(element.id());
mGraphicalApi.removeElement(element.id());
} else {
element.setAllGraphicalProperties(mGraphicalApi.properties(element.id()));
if (!mLogicalApi.logicalRepoApi().exist(element.logicalId())) {
mGraphicalApi.removeElement(element.id());
return;
}
element.setAllLogicalProperties(mGraphicalApi.properties(element.logicalId()));
const IdList graphicalIds = mGraphicalApi.graphicalIdsByLogicalId(element.logicalId());
mGraphicalApi.removeElement(element.id());
// Checking that the only graphical part is our element itself
// (bijection between graphical and logical parts)
if (graphicalIds.count() == 1 && graphicalIds[0] == element.id()) {
mLogicalApi.removeReferencesTo(element.logicalId());
mLogicalApi.removeReferencesFrom(element.logicalId());
mLogicalApi.removeElement(element.logicalId());
}
}
}
示例3: remove
void CreateRemoveCommandImplementation::remove()
{
if (mIsFromLogicalModel) {
mLogicalApi.removeReferencesTo(mId);
mLogicalApi.removeReferencesFrom(mId);
mLogicalApi.removeElement(mId);
mGraphicalApi.removeElement(mId);
} else {
mGraphicalPropertiesSnapshot = mGraphicalApi.properties(mId);
const Id logicalId = mGraphicalApi.logicalId(mId);
if (!mLogicalApi.logicalRepoApi().exist(logicalId)) {
mGraphicalApi.removeElement(mId);
refreshAllPalettes();
return;
}
mOldLogicalId = logicalId;
mLogicalPropertiesSnapshot = mGraphicalApi.properties(logicalId);
const IdList graphicalIds = mGraphicalApi.graphicalIdsByLogicalId(logicalId);
mGraphicalApi.removeElement(mId);
// Checking that the only graphical part is our element itself
// (bijection between graphical and logical parts)
if (graphicalIds.count() == 1 && graphicalIds[0] == mId) {
mLogicalApi.removeReferencesTo(logicalId);
mLogicalApi.removeReferencesFrom(logicalId);
mLogicalApi.removeElement(logicalId);
}
}
refreshAllPalettes();
}
示例4: initNextBlocks
bool DummyBlock::initNextBlocks()
{
IdList const links = mGraphicalModelApi->graphicalRepoApi().outgoingLinks(id());
if (links.count() == 0) {
mNextBlockId = Id();
} else {
mNextBlockId = mGraphicalModelApi->graphicalRepoApi().otherEntityFromLink(links[0], id());
}
return true;
}
示例5: createIdByLineCorrelation
void VisualDebugger::createIdByLineCorrelation(UML::Element *elem, int& line)
{
UML::Element *curElem = dynamic_cast<UML::NodeElement *>(elem);
if (curElem && elem->id().element().compare("InitialNode") != 0) {
if (elem->id().element().compare("Action") == 0) {
mIdByLineCorrelation[line] = elem->id();
line++;
if (mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).count() != 0) {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextEdge), line);
} else {
error(missingEndNode);
mHasNotEndWithFinalNode = true;
}
} else {
if (elem->id().element().compare("ConditionNode") == 0) {
mIdByLineCorrelation[line] = elem->id();
line++;
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id());
Id falseEdge = falseEdge.rootId();
Id trueEdge = trueEdge.rootId();
for (int i=0; i<outLinks.count(); i++) {
bool type = getProperty(outLinks.at(i), "type").toBool();
if (type) {
trueEdge = outLinks.at(i);
} else {
falseEdge = outLinks.at(i);
}
}
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(trueEdge), line);
line++;
if (falseEdge != falseEdge.rootId()) {
line++;
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(falseEdge), line);
line++;
}
} else {
mIdByLineCorrelation[line] = elem->id();
}
}
} else {
if (elem->id().element().compare("InitialNode") != 0) {
Id nextNode = mLogicalModelApi.logicalRepoApi().to(elem->id());
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextNode), line);
} else {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextEdge), line);
}
}
}
示例6: findValidLink
Id VisualDebugger::findValidLink()
{
IdList outLinks = mModelApi.graphicalRepoApi().outgoingLinks(mCurrentId);
QString conditionStr = mModelApi.graphicalRepoApi().property(mCurrentId, "condition").toString();
int pos=0;
bool condition = mBlockParser->parseCondition(conditionStr, pos, mCurrentId);
for (int i=0; i<outLinks.count(); i++) {
bool type = mModelApi.graphicalRepoApi().property(outLinks.at(i), "type").toBool();
if (type == condition) {
return outLinks.at(i);
}
}
if (!mBlockParser->hasErrors()) {
error(VisualDebugger::missingValidLink);
}
return ROOT_ID;
}
示例7: acceptPropertyModifications
void EditPropertiesDialog::acceptPropertyModifications()
{
if (mPropertyName.isEmpty()) {
const IdList sameNameProperties = mInterpreterEditorManager.propertiesWithTheSameName(mId, ""
, mUi->displayedNameEdit->text());
if (sameNameProperties.isEmpty()) {
mPropertyName = mUi->displayedNameEdit->text();
} else {
mPropertyName = mUi->displayedNameEdit->text() + "_" + sameNameProperties.count();
}
mInterpreterEditorManager.addProperty(mId, mPropertyName);
// set property default value for elements on diagram
for (const auto &elementOnDiagram: mElementsOnDiagram) {
mApi.setProperty(elementOnDiagram, mPropertyName, mUi->defaultValueEdit->text());
}
mElementsOnDiagram.clear();
}
if (mMode == editExisting
&& mInterpreterEditorManager.typeName(mId, mPropertyName) != mUi->attributeTypeEdit->text()
)
{
// TODO: Remove connects.
QMessageBox messageBox(tr("Warning:")
, tr("You changed the type of property. In case of incorrect conversion it may"
" result in resetting of the existing property value.")
, QMessageBox::Warning, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
messageBox.button(QMessageBox::Ok)->setText(tr("Proceed anyway"));
messageBox.button(QMessageBox::Cancel)->setText(tr("Cancel the type conversion"));
connect(messageBox.button(QMessageBox::Cancel), &QAbstractButton::clicked
, this, &EditPropertiesDialog::messageBoxCancel);
connect(messageBox.button(QMessageBox::Ok), &QAbstractButton::clicked
, this, &EditPropertiesDialog::updateProperties);
messageBox.exec();
} else {
updateProperties();
}
}
示例8: okButtonClicked
void EdgePropertiesDialog::okButtonClicked()
{
if (mUi->nameEdit->text().isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("All required properties should be filled!"));
} else {
mEdgeName = mUi->nameEdit->text();
IdList const edgesWithTheSameNameList = mEditorManagerProxy.elementsWithTheSameName(mDiagram
, mUi->nameEdit->text(), "MetaEntityEdge");
if (!edgesWithTheSameNameList.isEmpty()) {
mEdgeName = mUi->nameEdit->text() + "_" + edgesWithTheSameNameList.count();
mRestoreElementDialog = new RestoreElementDialog(this, mMainWindow, mEditorManagerProxy, edgesWithTheSameNameList);
mRestoreElementDialog->setModal(true);
mRestoreElementDialog->show();
connect(mRestoreElementDialog, &qReal::RestoreElementDialog::createNewChosen
, this, &EdgePropertiesDialog::addEdgeElement);
connect(mRestoreElementDialog, &qReal::RestoreElementDialog::restoreChosen
, this, &EdgePropertiesDialog::done);
} else {
addEdgeElement();
}
}
}
示例9: settings
gui::ErrorReporter& VisualDebugger::debug()
{
if (VisualDebugger::noErrors != checkEditor()) {
return *mErrorReporter;
}
mDebugType = VisualDebugger::fullDebug;
QSettings settings("SPbSU", "QReal");
setTimeout(settings.value("debuggerTimeout", 750).toInt());
setDebugColor(settings.value("debugColor").toString());
if (VisualDebugger::noErrors != doFirstStep(findBeginNode("InitialNode"))) {
return *mErrorReporter;
}
mBlockParser->setErrorReporter(mErrorReporter);
IdList outLinks = mModelApi.graphicalRepoApi().outgoingLinks(mCurrentId);
while (outLinks.count() > 0) {
pause(mTimeout);
if (mCurrentElem->newType().element().compare("ConditionNode") == 0) {
Id validLinkId = findValidLink();
if (mBlockParser->hasErrors()) {
deinitialize();
return *mErrorReporter;
}
if (validLinkId != ROOT_ID) {
doStep(validLinkId);
} else {
return *mErrorReporter;
}
} else {
doStep(outLinks.at(0));
if (mBlockParser->hasErrors()) {
deinitialize();
return *mErrorReporter;
}
}
pause(mTimeout);
if (!hasEndOfLinkNode(mCurrentId)) {
error(VisualDebugger::missingEndOfLinkNode);
return *mErrorReporter;
}
doStep(mModelApi.graphicalRepoApi().to(mCurrentId));
if (mBlockParser->hasErrors()) {
deinitialize();
return *mErrorReporter;
}
outLinks = mModelApi.graphicalRepoApi().outgoingLinks(mCurrentId);
}
pause(mTimeout);
if (!isFinalNode(mCurrentId)) {
error(VisualDebugger::endWithNotEndNode);
return *mErrorReporter;
}
mErrorReporter->addInformation("Debug finished successfully");
deinitialize();
return *mErrorReporter;
}
示例10: isFinalNode
bool VisualDebugger::isFinalNode(Id id)
{
IdList outLinks = mModelApi.graphicalRepoApi().outgoingLinks(id);
return outLinks.count() == 0 && mModelApi.type(id).element().compare("BlockFinalNode") == 0;
}
示例11: generateCode
void VisualDebugger::generateCode(UML::Element *elem, QFile &codeFile)
{
UML::Element *curElem = dynamic_cast<UML::NodeElement *>(elem);
if (curElem && elem->id().element().compare("InitialNode") != 0) {
if (elem->id().element().compare("Action") == 0) {
QString code = getProperty(curElem->id(), "process").toString();
if (code.mid(0,4).compare("var ") == 0) {
codeFile.write(code.mid(4).toAscii());
} else {
codeFile.write(code.toAscii());
}
codeFile.write("\n");
if (mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).count() != 0) {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
generateCode(mEditor->mvIface()->scene()->getElem(nextEdge), codeFile);
} else {
error(VisualDebugger::missingEndNode);
error(codeGenerationError);
return;
}
} else {
if (elem->id().element().compare("ConditionNode") == 0) {
codeFile.write("if (");
codeFile.write(getProperty(curElem->id(), "condition").toByteArray());
codeFile.write(") {\n");
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id());
Id falseEdge = falseEdge.rootId();
Id trueEdge = trueEdge.rootId();
for (int i=0; i<outLinks.count(); i++) {
bool type = getProperty(outLinks.at(i), "type").toBool();
if (type) {
trueEdge = outLinks.at(i);
} else {
falseEdge = outLinks.at(i);
}
}
if (trueEdge == trueEdge.rootId()) {
error(VisualDebugger::missingValidLink);
error(codeGenerationError);
return;
}
generateCode(mEditor->mvIface()->scene()->getElem(trueEdge), codeFile);
codeFile.write("}\n");
if (falseEdge != falseEdge.rootId()) {
codeFile.write("else {\n");
generateCode(mEditor->mvIface()->scene()->getElem(falseEdge), codeFile);
codeFile.write("}\n");
}
}
}
} else {
if (elem->id().element().compare("InitialNode") != 0) {
Id nextNode = mLogicalModelApi.logicalRepoApi().to(elem->id());
generateCode(mEditor->mvIface()->scene()->getElem(nextNode), codeFile);
} else {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
generateCode(mEditor->mvIface()->scene()->getElem(nextEdge), codeFile);
}
}
return;
}
示例12: debug
void VisualDebugger::debug()
{
mDebugType = VisualDebugger::fullDebug;
QSettings settings("SPbSU", "QReal");
setTimeout(settings.value("debuggerTimeout", 750).toInt());
if (VisualDebugger::noErrors != doFirstStep(findBeginNode("InitialNode"))) {
return;
}
mBlockParser->setErrorReporter(mInterpretersInterface.errorReporter());
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(mCurrentId);
while (outLinks.count() > 0) {
pause(mTimeout);
if (mCurrentElem->id().element().compare("ConditionNode") == 0) {
Id validLinkId = findValidLink();
if (mBlockParser->hasErrors()) {
deinitialize();
return;
}
if (validLinkId != Id::rootId()) {
doStep(validLinkId);
} else {
return;
}
} else {
doStep(outLinks.at(0));
if (mBlockParser->hasErrors()) {
deinitialize();
return;
}
}
pause(mTimeout);
if (!hasEndOfLinkNode(mCurrentId)) {
error(VisualDebugger::missingEndOfLinkNode);
return;
}
doStep(mLogicalModelApi.logicalRepoApi().to(mCurrentId));
if (mBlockParser->hasErrors()) {
deinitialize();
return;
}
outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(mCurrentId);
}
pause(mTimeout);
if (!isFinalNode(mCurrentId)) {
error(VisualDebugger::endWithNotEndNode);
return;
}
mInterpretersInterface.errorReporter()->addInformation("Debug finished successfully");
deinitialize();
return;
}
示例13: isFinalNode
bool VisualDebugger::isFinalNode(Id id)
{
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(id);
return outLinks.count() == 0 && id.element().compare("BlockFinalNode") == 0;
}