本文整理汇总了C++中model::Model::beginModification方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::beginModification方法的具体用法?C++ Model::beginModification怎么用?C++ Model::beginModification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model::Model
的用法示例。
在下文中一共展示了Model::beginModification方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(FilePersistence, SaveMultipleUnits)
{
QString testDir = QDir::tempPath() + QDir::toNativeSeparators("/Envision/FilePersistence/tests");
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.createRoot("BinaryNode"));
model.beginModification(root, "set title");
root->name()->set("Root");
TestNodes::BinaryNode* left = root->setLeft<TestNodes::BinaryNodePersistenceUnit>();
TestNodes::BinaryNode* right = root->setRight<TestNodes::BinaryNode>();
left->name()->set("Left child");
TestNodes::BinaryNode* leftleft = left->setLeft<TestNodes::BinaryNode>();
leftleft->name()->set("in a new unit");
right->name()->set("Right child");
model.endModification();
model.setName("units");
model.save(&store);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/units", testDir + "/units/units");
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/2", testDir + "/units/2");
}
示例2:
TEST(FilePersistence, SaveList)
{
QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests";
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.createRoot("PartialList"));
model.beginModification(root, "create ");
Model::Text* one = new Model::Text();
one->set("one");
root->list()->append(one);
Model::Text* two = new Model::Text();
two->set("two");
root->list()->append(two);
Model::Text* three = new Model::Text();
three->set("three");
root->list()->append(three);
Model::Text* four = new Model::Text();
four->set("four");
root->list()->append(four);
model.endModification();
model.setName("partial");
model.save(&store);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partial/partial", testDir + "/partial/partial");
}
示例3:
TEST(OOModel, SimpleProjectTest)
{
Model::Model model;
Project* root = dynamic_cast<Project*> (model.createRoot("Project"));
CHECK_CONDITION(root != nullptr);
CHECK_CONDITION(root->name().isEmpty());
model.beginModification(root, "setName");
root->setName("prj");
model.endModification();
CHECK_STR_EQUAL("prj", root->name());
}
示例4: srcDir
TEST(FilePersistence, ReSaveList)
{
QString srcDir(":/FilePersistence/test/persisted");
QString destDir(QDir::tempPath() + "/Envision/FilePersistence/tests");
QFile src(srcDir + "/partial/partial");
QFile dest(destDir + "/partialResave/partialResave");
if (dest.exists())
{
bool removed = dest.remove();
CHECK_CONDITION(removed);
}
if (!QDir(destDir + "/partialResave").exists())
{
bool createdDir = QDir().mkpath(destDir + "/partialResave");
CHECK_CONDITION(createdDir);
}
bool copied = src.copy(dest.fileName());
CHECK_CONDITION(copied);
bool permissionOk = dest.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
CHECK_CONDITION(permissionOk);
Model::Model model;
FileStore store;
store.setBaseFolder(destDir);
model.load(&store, "partialResave");
TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.root());
CHECK_CONDITION(root->list()->isFullyLoaded() == false);
model.beginModification(root->list(), "fake modification ");
model.endModification();
CHECK_CONDITION(root->list()->isFullyLoaded() == false);
model.setName("partialResave");
model.save(&store);
CHECK_CONDITION(root->list()->isFullyLoaded() == false);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partialResave/partialResave", destDir + "/partialResave/partialResave");
}
示例5: TestBoxNode
TEST(VisualizationBase, ExtendableTest)
{
Model::Model* model = new Model::Model();
Model::List* list = static_cast<Model::List*> (model->createRoot("List"));
model->beginModification(list, "set");
TestNodes::BinaryNode* first = new TestNodes::BinaryNode();
list->append(first);
TestNodes::BinaryNode* second = new TestNodes::BinaryNode();
list->append(second);
Model::Text* third = new Model::Text();
list->append(third);
first->name()->set("First node");
TestNodes::BinaryNode* left = new TestNodes::BinaryNode();
first->setLeft(left);
TestNodes::BinaryNode* right = new TestNodes::BinaryNode();
first->setRight(right);
left->name()->set("left node");
right->name()->set("right node");
second->name()->set("Empty node");
third->set("Some independent text");
list->append(new TestBoxNode("someText"));
list->append(new TestBoxNode("stretch", true));
model->endModification();
auto top = new RootItem(list);
auto scene = VisualizationManager::instance().mainScene();
scene->addTopLevelItem( top );
QApplication::processEvents();
VList* l = dynamic_cast<VList*> (top->item());
l->itemAt<VExtendable>(1)->setExpanded(false);
scene->scheduleUpdate();
scene->listenToModel(model);
CHECK_CONDITION(scene);
}
示例6: Scene
TEST(InteractionBase, TextSelect)
{
Scene* scene = new Scene();
Model::Model* model = new Model::Model();
Model::List* list = static_cast<Model::List*> (model->createRoot("List"));
model->beginModification(list, "set");
TestNodes::BinaryNode* first = new TestNodes::BinaryNode();
list->append(first);
TestNodes::BinaryNode* second = new TestNodes::BinaryNode();
list->append(second);
Model::Text* third = new Model::Text();
list->append(third);
first->name()->set("First node");
TestNodes::BinaryNode* left = new TestNodes::BinaryNode();
first->setLeft(left);
TestNodes::BinaryNode* right = new TestNodes::BinaryNode();
first->setRight(right);
left->name()->set("left node");
right->name()->set("right node");
second->name()->set("Empty node");
third->set("Some independent text");
model->endModification();
VList* l = dynamic_cast<VList*> (scene->renderer()->render(nullptr, list));
scene->addTopLevelItem(l);
scene->scheduleUpdate();
QApplication::processEvents();
l->at<VExtendable>(0)->setExpanded();
scene->scheduleUpdate();
scene->listenToModel(model);
// Create view
MainView* view = new MainView(scene);
CHECK_CONDITION(view != nullptr);
}
示例7:
TEST(FilePersistence, SavingTypedList)
{
QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests";
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
Model::TypedList<Model::Text>* list = dynamic_cast<Model::TypedList<Model::Text>*> (model.createRoot("TypedListOfText"));
model.beginModification(list, "create");
Model::Text* one = new Model::Text();
one->set("one");
list->append(one);
Model::Text* two = new Model::Text();
two->set("two");
list->append(two);
model.endModification();
model.setName("typedList");
model.save(&store);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/typedList/typedList", testDir + "/typedList/typedList");
}
示例8:
TEST(OOModel, JavaLibraryAndHelloWorldTest)
{
Model::Model model;
Project* prj = dynamic_cast<Project*> (model.createRoot("Project"));
model.beginModification(prj, "build simple java library and a hello world app");
prj->setName("HelloWorld");
// Build a simple Java Library
Library* java = prj->libraries()->append<Library>();
java->setName("Java");
Class* string = java->classes()->append<Class>();
string->setName("String");
string->setVisibility(Visibility::PUBLIC);
Module* io = java->modules()->append<Module>();
io->setName("io");
Class* printstream = io->classes()->append<Class>();
printstream->setName("PrintStream");
printstream->setVisibility(Visibility::PUBLIC);
Method* println = printstream->methods()->append<Method>();
println->setName("println");
println->setVisibility(Visibility::PUBLIC);
FormalArgument* arg = println->arguments()->append<FormalArgument>();
arg->setName("x");
NamedType* argType = arg->setType<NamedType>();
argType->type()->ref()->set("class:String");
Class* system = java->classes()->append<Class>();
system->setName("System");
system->setVisibility(Visibility::PUBLIC);
Field* out = system->fields()->append<Field>();
out->setName("out");
out->setVisibility(Visibility::PUBLIC);
out->setStorageSpecifier(StorageSpecifier::CLASS_VARIABLE);
NamedType* outtype = out->setType<NamedType>();
outtype->type()->ref()->set("class:PrintStream");
outtype->type()->setPrefix<ReferenceExpression>()->ref()->set("mod:io");
// Build a simple HelloWorld Application
Class* hello = prj->classes()->append<Class>();
hello->setName("HelloWorld");
hello->setVisibility(Visibility::PUBLIC);
Method* main = hello->methods()->append<Method>();
main->setName("main");
main->setVisibility(Visibility::PUBLIC);
main->setStorageSpecifier(StorageSpecifier::CLASS_VARIABLE);
//TODO make an array argument
MethodCallStatement* callPrintln = main->items()->append<MethodCallStatement>();
StringLiteral* helloStr = callPrintln->arguments()->append<StringLiteral>();
helloStr->setValue("Hello World");
callPrintln->ref()->set("met:println");
VariableAccess* va = callPrintln->setPrefix<VariableAccess>();
va->ref()->set("field:out");
ReferenceExpression* ref = va->setPrefix<ReferenceExpression>();
ref->ref()->set("lib:Java,class:System");
model.endModification();
CHECK_STR_EQUAL("Java", java->name());
CHECK_CONDITION(callPrintln->methodDefinition() != nullptr);
CHECK_CONDITION(callPrintln->methodDefinition() == println);
}