Mercurial > hg > svgui
comparison layer/LayerFactory.cpp @ 336:4a542ba875c2
* Improvements to layer summary dialog (LayerTree, LayerTreeDialog), & rename.
It's still rather unstable though.
author | Chris Cannam |
---|---|
date | Wed, 28 Nov 2007 17:45:37 +0000 |
parents | 29fcf125f98b |
children | 369a197737c7 0895517bb2d1 |
comparison
equal
deleted
inserted
replaced
335:2f83b6e3b8ca | 336:4a542ba875c2 |
---|---|
416 | 416 |
417 if (!layer) { | 417 if (!layer) { |
418 std::cerr << "LayerFactory::createLayer: Unknown layer type " | 418 std::cerr << "LayerFactory::createLayer: Unknown layer type " |
419 << type << std::endl; | 419 << type << std::endl; |
420 } else { | 420 } else { |
421 std::cerr << "LayerFactory::createLayer: Setting object name " | 421 // std::cerr << "LayerFactory::createLayer: Setting object name " |
422 << getLayerPresentationName(type).toStdString() << " on " << layer << std::endl; | 422 // << getLayerPresentationName(type).toStdString() << " on " << layer << std::endl; |
423 layer->setObjectName(getLayerPresentationName(type)); | 423 layer->setObjectName(getLayerPresentationName(type)); |
424 setLayerDefaultProperties(type, layer); | 424 setLayerDefaultProperties(type, layer); |
425 } | 425 } |
426 | 426 |
427 return layer; | 427 return layer; |
428 } | 428 } |
429 | 429 |
430 void | 430 void |
431 LayerFactory::setLayerDefaultProperties(LayerType type, Layer *layer) | 431 LayerFactory::setLayerDefaultProperties(LayerType type, Layer *layer) |
432 { | 432 { |
433 std::cerr << "LayerFactory::setLayerDefaultProperties: type " << type << " (name \"" << getLayerTypeName(type).toStdString() << "\"" << std::endl; | 433 // std::cerr << "LayerFactory::setLayerDefaultProperties: type " << type << " (name \"" << getLayerTypeName(type).toStdString() << "\")" << std::endl; |
434 | 434 |
435 QSettings settings; | 435 QSettings settings; |
436 settings.beginGroup("LayerDefaults"); | 436 settings.beginGroup("LayerDefaults"); |
437 QString defaults = settings.value(getLayerTypeName(type), "").toString(); | 437 QString defaults = settings.value(getLayerTypeName(type), "").toString(); |
438 if (defaults == "") return; | 438 if (defaults == "") return; |
439 | 439 |
440 std::cerr << "defaults=\"" << defaults.toStdString() << "\"" << std::endl; | 440 // std::cerr << "defaults=\"" << defaults.toStdString() << "\"" << std::endl; |
441 | 441 |
442 QString xml = layer->toXmlString(); | 442 QString xml = layer->toXmlString(); |
443 QDomDocument docOld, docNew; | 443 QDomDocument docOld, docNew; |
444 | 444 |
445 if (docOld.setContent(xml, false) && | 445 if (docOld.setContent(xml, false) && |
451 QDomNamedNodeMap attrNodes = layerElt.attributes(); | 451 QDomNamedNodeMap attrNodes = layerElt.attributes(); |
452 | 452 |
453 for (unsigned int i = 0; i < attrNodes.length(); ++i) { | 453 for (unsigned int i = 0; i < attrNodes.length(); ++i) { |
454 QDomAttr attr = attrNodes.item(i).toAttr(); | 454 QDomAttr attr = attrNodes.item(i).toAttr(); |
455 if (attr.isNull()) continue; | 455 if (attr.isNull()) continue; |
456 std::cerr << "append \"" << attr.name().toStdString() | 456 // std::cerr << "append \"" << attr.name().toStdString() |
457 << "\" -> \"" << attr.value().toStdString() << "\"" | 457 // << "\" -> \"" << attr.value().toStdString() << "\"" |
458 << std::endl; | 458 // << std::endl; |
459 attrs.append(attr.name(), "", "", attr.value()); | 459 attrs.append(attr.name(), "", "", attr.value()); |
460 } | 460 } |
461 | 461 |
462 layerElt = docOld.firstChildElement("layer"); | 462 layerElt = docOld.firstChildElement("layer"); |
463 attrNodes = layerElt.attributes(); | 463 attrNodes = layerElt.attributes(); |
464 for (unsigned int i = 0; i < attrNodes.length(); ++i) { | 464 for (unsigned int i = 0; i < attrNodes.length(); ++i) { |
465 QDomAttr attr = attrNodes.item(i).toAttr(); | 465 QDomAttr attr = attrNodes.item(i).toAttr(); |
466 if (attr.isNull()) continue; | 466 if (attr.isNull()) continue; |
467 if (attrs.value(attr.name()) == "") { | 467 if (attrs.value(attr.name()) == "") { |
468 std::cerr << "append \"" << attr.name().toStdString() | 468 // std::cerr << "append \"" << attr.name().toStdString() |
469 << "\" -> \"" << attr.value().toStdString() << "\"" | 469 // << "\" -> \"" << attr.value().toStdString() << "\"" |
470 << std::endl; | 470 // << std::endl; |
471 attrs.append(attr.name(), "", "", attr.value()); | 471 attrs.append(attr.name(), "", "", attr.value()); |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 layer->setProperties(attrs); | 475 layer->setProperties(attrs); |