BaseObject.cc 21.9 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40 41
\*===========================================================================*/

42 43 44 45 46 47 48 49 50 51

//=============================================================================
//
//  MyTypes
//
//=============================================================================


//== INCLUDES =================================================================

52
#include "BaseObjectCore.hh"
53
#include "Types.hh"
54
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
55 56
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>

Jan Möbius's avatar
Jan Möbius committed
57 58 59
#include <QJsonDocument>
#include <QJsonObject>

60 61 62

//== TYPEDEFS =================================================================

Jan Möbius's avatar
Jan Möbius committed
63 64
//== Variables =================================================================

65 66 67 68 69 70 71
//== CLASS DEFINITION =========================================================

/** This counter is used to provide unique object ids. Every time a object is created
 * the counter is incremented and a new objectId given to the object. DONT TOUCH IT.
 */
static int idGenerator = 1;

72 73 74 75 76
/** Static member for no object initialization
 *
 */
int BaseObject::NOOBJECT = -1;

77
BaseObject::BaseObject(const BaseObject& _object) :
78 79 80 81 82 83
  QObject(),
  id_(idGenerator),
  persistentId_(_object.persistentId_),
  objectType_(_object.objectType_),
  flags_(_object.flags_),
  visible_(_object.visible_),
84 85
  parentItem_(0),
  path_("."),
86 87
  filename_(""),
  commentsByKey_(_object.commentsByKey_)
88

89
{
90
  // Increase id generator as we created a new object
91
  ++idGenerator;
92 93

  // Generate a usable name based on the copied object
94 95
  name_ = "Copy of " + _object.name_;

96
  childItems_.clear();
97
  dataMap_.clear();
98
  
99 100 101 102 103 104 105 106 107 108 109 110
  // Iterate over all per Object datas and try to copy them
  QMap< QString, PerObjectData* >::const_iterator mapIter = _object.dataMap_.begin();  
  while ( mapIter != _object.dataMap_.end() ) {
    // Try to get a copy of the object.
    PerObjectData* copiedData = mapIter.value()->copyPerObjectData();
    
    if ( copiedData ) {
      dataMap_.insert(mapIter.key(),copiedData);
    } else {
      std::cerr << "Failed to copy per Object Data: " << mapIter.key().toStdString() << std::endl;
    }
    
Jan Möbius's avatar
Jan Möbius committed
111
    ++mapIter;
112 113
  }
  
114 115 116
  // If the pointer is 0 then we are creating the object root
  // and we do not have anything to attach this object to
  // otherwise, we attach the new object to the object root
117
  if ( PluginFunctions::objectRoot() ) {
118

119 120
    setParent(PluginFunctions::objectRoot());
    PluginFunctions::objectRoot()->appendChild(this);
121 122

    // New object
123
    PluginFunctions::increaseObjectCount();
124 125 126 127

    // If the new one is target, we also have to track this
    if ( target() )
      PluginFunctions::increaseTargetCount();
128 129
  }
  
130 131 132
  // Add object to object container
  PluginFunctions::addObjectToMap( id(), this );
  
133
  getObjectManager()->objectCreated(id());
134
}
135 136

BaseObject::BaseObject(BaseObject* _parent) :
137
  QObject() ,
138 139
  id_(-1),
  persistentId_(-1),
140
  objectType_(DATA_UNKNOWN),
Jan Möbius's avatar
Jan Möbius committed
141
  flags_(),
142 143 144 145 146 147
  visible_(true),
  parentItem_(_parent),
  name_("NONAME")
{
  id_ = idGenerator;
  ++ idGenerator;
148
  
149
  // If the pointer is 0 then something went wrong or we are the root node
150
  if ( _parent ) {
Jan Möbius's avatar
Jan Möbius committed
151
    
152
    _parent->appendChild(this);
153
    PluginFunctions::increaseObjectCount();
154
    
Jan Möbius's avatar
Jan Möbius committed
155
  } else {
156 157 158 159
    
    if ( PluginFunctions::objectRoot() ) {
      setParent(PluginFunctions::objectRoot());
      PluginFunctions::objectRoot()->appendChild(this);
160
      PluginFunctions::increaseObjectCount();
161 162
    }
    
163 164
  }
  
165 166 167
  // Add object to object container
  PluginFunctions::addObjectToMap( id(), this );
  
168
  getObjectManager()->objectCreated(id());
169 170
}

171

172 173 174
BaseObject::~BaseObject() {

  deleteData();
175 176 177
  
  PluginFunctions::decreaseObjectCount();
  
178 179 180
  if ( target() )
    PluginFunctions::decreaseTargetCount();
  
181
  getObjectManager()->objectDeleted(id());
182 183 184 185 186 187 188 189

}


// ===============================================================================
// Object Identification
// ===============================================================================

190
int BaseObject::id() const {
191 192 193
  return id_;
}

194
int BaseObject::persistentId() const {
195 196 197 198 199 200 201 202 203 204 205 206 207 208
  return persistentId_;
}

void BaseObject::persistentId( int _id ) {
  persistentId_ = _id;
}


// ===============================================================================
// Data
// ===============================================================================

void BaseObject::cleanup() {
  persistentId_ = -1;
209
  path_       = ".";
Jan Möbius's avatar
Jan Möbius committed
210 211
  flags_.clear();

212 213
  visible_    = true;
  name_       = "NONAME";
214
  filename_ = "";
215 216 217 218 219 220
}

// ===============================================================================
// Data Type Handling
// ===============================================================================

221
bool BaseObject::dataType(DataType _type) const {
222 223 224 225 226
  if ( _type == DATA_ALL ) {
    return true;
  }

  return ( objectType_ & _type);
227 228
}

229
DataType BaseObject::dataType() const {
230 231 232 233
  return BaseObject::objectType_;
}

void BaseObject::setDataType(DataType _type) {
234
  if ( objectType_ != DATA_UNKNOWN )
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
    std::cerr << "BaseObect : overwriting data type" << std::endl;
  objectType_ = _type;
}

// ===============================================================================
// Object Information
// ===============================================================================


QString BaseObject::getObjectinfo() {
  QString output;

  output += "Info for Object with id " + QString::number(id()) +"\n";
  output += "Object is : ";
  if ( target() )
    output += "target ";
  if ( source() )
    output += " source";

  if ( visible() )
    output += " visible";
  else
    output += " invisible";

  output +="\n";

  return output;
}

void BaseObject::printObjectInfo() {
  std::cout << getObjectinfo().toStdString();
}


// ===============================================================================
Jan Möbius's avatar
Jan Möbius committed
270
// flag Handling
271 272 273
// ===============================================================================

bool BaseObject::target() {
Jan Möbius's avatar
Jan Möbius committed
274
  return flag("target");
275 276 277
}

void BaseObject::target(bool _target) {
278

279 280 281 282 283 284 285 286
  if ( target() != _target ) {
    
    if ( _target )
      PluginFunctions::increaseTargetCount();
    else
      PluginFunctions::decreaseTargetCount();
  }
  
Jan Möbius's avatar
Jan Möbius committed
287
  setFlag("target", _target);
288
  
289 290 291
}

bool BaseObject::source() {
Jan Möbius's avatar
Jan Möbius committed
292
  return flag("source");
293 294 295
}

void BaseObject::source(bool _source) {
296
  setFlag("source", _source);
Jan Möbius's avatar
Jan Möbius committed
297 298 299 300 301 302 303 304 305
}

bool BaseObject::flag(QString _flag)
{
  return flags_.contains(_flag);
}

void BaseObject::setFlag(QString _flag, bool _set)
{
306 307
  bool emitted = false;
  
Jan Möbius's avatar
Jan Möbius committed
308 309
  if (flags_.contains(_flag))
  {
310
    if (!_set) {
Jan Möbius's avatar
Jan Möbius committed
311
      flags_.removeAll(_flag);
312
      emit objectSelectionChanged(id());
313
      emitted = true;
314
    }
Jan Möbius's avatar
Jan Möbius committed
315 316 317
  }
  else
  {
318
    if (_set) {
Jan Möbius's avatar
Jan Möbius committed
319
      flags_ << _flag;
320
      emit objectSelectionChanged(id());
321
      emitted = true;
322
    }
Jan Möbius's avatar
Jan Möbius committed
323
  }
324
  
325 326 327
  //always emit if its a group
  if ( !emitted && isGroup() )
    emit objectSelectionChanged(id());
Jan Möbius's avatar
Jan Möbius committed
328 329 330 331 332
}

QStringList BaseObject::flags()
{
  return flags_;
333 334 335 336 337 338 339 340 341 342
}

// ===============================================================================
// Object visualization
// ===============================================================================

bool BaseObject::visible() {
  return visible_;
}

343
void BaseObject::visible(bool _visible) {
344 345 346
  // Only do something if this is really a change
  if (  visible_ != _visible ) {
    visible_ = _visible;
347 348 349 350 351 352 353 354
    
    emit visibilityChanged( id() );
    
  } else {
    
    //always emit if its a group
    if ( isGroup() )
      emit visibilityChanged( id() );
355
  }
356 357
}

358 359 360 361 362 363
// ===============================================================================
// ===============================================================================
// Tree Structure :
// ===============================================================================
// ===============================================================================

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
BaseObject* BaseObject::last() {
  //indexOf

//   // Visit child item of this node
//   if ( childItems_.size() > 0 ) {
//      return childItems_[0];
//   }
//
//   // No Child Item so visit the next child of the parentItem_
//   if ( parentItem_ ) {
//
//     BaseObject* parentPointer = parentItem_;
//     BaseObject* thisPointer   = this;
//
//     // while we are not at the root node
//     while ( parentPointer ) {
//
//       // If there is an unvisited child of the parent, return this one
//       if ( parentPointer->childCount() > ( thisPointer->row() + 1) ) {
//         return parentPointer->childItems_[ thisPointer->row() + 1 ];
//       }
//
//       // Go to the next level
//       thisPointer   = parentPointer;
//       parentPointer = parentPointer->parentItem_;
//
//     }
//
//     return thisPointer;
//   }
//
//   return this;
  std::cerr << "Last not implemented yet! " << std::endl;
  return 0;

}

// ===============================================================================
// ===============================================================================

404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
BaseObject* BaseObject::next() {
  // Visit child item of this node
  if ( childItems_.size() > 0 ) {
     return childItems_[0];
  }

  // No Child Item so visit the next child of the parentItem_
  if ( parentItem_ ) {

    BaseObject* parentPointer = parentItem_;
    BaseObject* thisPointer   = this;

    // while we are not at the root node
    while ( parentPointer ) {

      // If there is an unvisited child of the parent, return this one
420 421 422
      int nextIndex = ( thisPointer->row() + 1);
      if ( parentPointer->childCount() > nextIndex ) {
        return parentPointer->childItems_[ nextIndex ];
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
      }

      // Go to the next level
      thisPointer   = parentPointer;
      parentPointer = parentPointer->parentItem_;

    }

    return thisPointer;
  }

  return this;

}

438 439 440
// ===============================================================================
// ===============================================================================

441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
int BaseObject::level() {
  int level = 0;
  BaseObject* current = this;

  // Go up and count the levels to the root node
  while ( current->parent() != 0 ) {
    level++;
    current = current->parent();
  }

  return level;
}

// ===============================================================================
// Parent
// ===============================================================================

int BaseObject::row() const
{
460 461 462 463
    if (parentItem_)
        return parentItem_->childItems_.indexOf(const_cast<BaseObject*>(this));

    return 0;
464 465 466 467 468 469 470
}

BaseObject* BaseObject::parent()
{
  return parentItem_;
}

471 472 473 474 475
const BaseObject* BaseObject::parent() const
{
  return parentItem_;
}

476 477
/// Set the parent pointer
void BaseObject::setParent(BaseObject* _parent) {
478
  // remove this child from the old parents list
Jan Möbius's avatar
Jan Möbius committed
479
  if ( parentItem_ != 0 ) {
480
    parentItem_->removeChild(this);
Jan Möbius's avatar
Jan Möbius committed
481 482 483 484
   
    if ( !_parent->childItems_.contains(this) )
      _parent->appendChild(this);
  }
485 486
  
  // Store new parent
487
  parentItem_ = _parent;
488 489 490
  
  // Tell other plugins about this change
  emit objectPropertiesChanged(id());
491 492 493 494 495 496 497 498 499
}


// ===============================================================================
// Children
// ===============================================================================

void BaseObject::appendChild(BaseObject *item)
{
500
  if ( !childItems_.contains(item) )
501
    childItems_.append(item);
502
  else 
503
    std::cerr << "Warning! Trying to append a child twice! Remove the append calls from your File plugin!" << std::endl;
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
}

BaseObject *BaseObject::child(int row)
{
    return childItems_.value(row);
}

int BaseObject::childCount() const
{
    return childItems_.count();
}

BaseObject* BaseObject::childExists(int _objectId) {

  // Check if this object has the requested id
  if ( id_ == _objectId )
    return this;

  // search in children
  for ( int i = 0 ; i < childItems_.size(); ++i ) {
    BaseObject* tmp = childItems_[i]->childExists(_objectId);
    if ( tmp != 0)
      return tmp;
  }

  return 0;
}

BaseObject* BaseObject::childExists(QString _name) {

  // Check if this object has the requested id
  if ( name() == _name )
    return this;

  // search in children
  for ( int i = 0 ; i < childItems_.size(); ++i ) {
    BaseObject* tmp = childItems_[i]->childExists(_name);
    if ( tmp != 0)
      return tmp;
  }

  return 0;
}

void BaseObject::removeChild( BaseObject* _item ) {

550 551 552 553 554 555 556
  bool found = false;
  QList<BaseObject*>::iterator i;
  for (i = childItems_.begin(); i != childItems_.end(); ++i) {
     if ( *i == _item ) {
        found = true;
        break;
     }
557 558
  }

559 560 561
  if ( !found ) {
    std::cerr << "Illegal remove request" << std::endl;
    return;
562 563
  }

564
  childItems_.erase(i);
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
}

QList< BaseObject* > BaseObject::getLeafs() {

  QList< BaseObject* > items;

  for ( int i = 0 ; i < childItems_.size(); ++i ) {
    items = items + childItems_[i]->getLeafs();
  }

  // If we are a leave...
  if ( childCount() == 0 )
    items.push_back(this);

  return items;
}

void BaseObject::deleteSubtree() {

  // call function for all children of this node
  for ( int i = 0 ; i < childItems_.size(); ++i) {

    // remove the subtree recursively
    childItems_[i]->deleteSubtree();

    // delete child
    delete childItems_[i];
  }

  // clear the array
  childItems_.clear();
}

// ===============================================================================
// Grouping
// ===============================================================================
601
int BaseObject::group() const {
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
  // Skip root node
  if ( parent() == 0 )
    return -1;

  // Dont count root node as a group
  if ( parent()->parent() == 0 )
    return -1;

  // Only consider groups
  if ( !parent()->dataType(DATA_GROUP) )
    return -1;

  // Get the group id
  return ( parent()->id() );

}

619
bool BaseObject::isGroup() const {
620 621 622 623 624
//   return ( (childItems_.size() > 0) || dataType(DATA_GROUP) ) ;
  return ( dataType(DATA_GROUP) ) ;
};


625 626
bool BaseObject::isInGroup( int _id ) const {
  const BaseObject* current = this;
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641

  // Go up and check for the group id
  do {

    // Check if we found the id
    if ( current->id() == _id )
      return true;

    // Move on to parent object
    current = current->parent();
  } while ( current != 0 );

  return false;
}

642 643
bool BaseObject::isInGroup( QString _name ) const {
  const BaseObject* current = this;
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702

  // Go up and check for the group name
  do {

    // Check if this object is a group and if it has the serach name
    if ( current->dataType( DATA_GROUP ) && (current->name() == _name) )
      return true;

    // Move on to parent object
    current = current->parent();

  } while ( current != 0 );

  return false;
}

std::vector< int > BaseObject::getGroupIds() {
  std::vector< int > groups;

  BaseObject* current = this;

  // Go up and collect all groups in the given order
  do {

    // collect only groups
    if ( current->dataType( DATA_GROUP ) )
      // Skip the root Object
      if ( current->parent() != 0 )
        groups.push_back( current->id() );

    // Move on to parent object
    current = current->parent();
  } while ( current != 0 );

  return groups;
}

QStringList BaseObject::getGroupNames() {
  QStringList groups;

  BaseObject* current = this;

  // Go up and collect all groups in the given order
  do {

    // collect only groups
    if ( current->dataType( DATA_GROUP ) )
      // Skip the root Object
      if ( current->parent() != 0 )
        groups.push_back( current->name() );

    // Move on to parent object
    current = current->parent();
  } while ( current != 0 );

  return groups;
}

// ===============================================================================
703
// Name and path Handling
704
// ===============================================================================
705

706
QString BaseObject::filename() const
707 708 709 710 711 712 713 714 715 716
{
  return filename_;
}

void BaseObject::setFileName(const QString &_filename)
{
  filename_ = _filename;
}

void BaseObject::setFromFileName(const QString &_filename ) {
717
  QFileInfo file_info(_filename);
718 719 720
  setPath(file_info.path());
  QString filename = file_info.fileName();
  setFileName(filename);
721 722
}

723
void BaseObject::setName(QString _name ) {
724
  name_ = _name;
725

726 727
  // Tell plugins about the name change
  emit objectPropertiesChanged(id());
728 729
}

730
QString BaseObject::name() const {
731 732 733
  return name_;
}

734
QString BaseObject::path() const {
735 736 737
  return path_;
}

738
void BaseObject::setPath(const QString &_path ) {
739
  path_ = _path;
740 741 742 743 744
}

// ===============================================================================
// Content
// ===============================================================================
Dirk Wilden's avatar
Dirk Wilden committed
745
void BaseObject::update(UpdateType /*_type*/) {
746 747 748 749 750 751 752 753 754
}

void BaseObject::dumpTree() {

  // Add spaces to visualize level
  for ( int i = 0 ; i < level() ; ++i  )
    std::cerr << "   ";

  std::cerr << "Node ";
755
  std::cerr << std::string(name().toLatin1());
756 757 758 759 760

  std::cerr << " with id : ";
  std::cerr << id();

  // Write the type of this Object
761
  std::cerr << " and type " << typeName(dataType()).toStdString()  <<  std::endl;
762 763 764 765 766 767 768

  // call function for all children of this node
  for ( int i = 0 ; i < childItems_.size(); ++i)
    childItems_[i]->dumpTree();

}

769 770 771 772 773
BaseObject* BaseObject::copy() {
  std::cerr << "Copy not supported by this Object" << std::endl;
  return  0;
}

774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823

// ===============================================================================
// per Object data functions
// ===============================================================================

void
BaseObject::
setObjectData( QString _dataName , PerObjectData* _data ) {
  dataMap_.insert( _dataName, _data );
}

void
BaseObject::
clearObjectData( QString _dataName ) {
  if (dataMap_.contains(_dataName))
    dataMap_.remove(_dataName);
}


bool
BaseObject::
hasObjectData( QString _dataName )
{
  return dataMap_.contains(_dataName);
}


PerObjectData*
BaseObject::
objectData( QString _dataName ) {
  if (dataMap_.contains(_dataName))
    return dataMap_.value(_dataName);
  else
    return 0;
}

void
BaseObject::
deleteData() {

  QMapIterator<QString, PerObjectData* > i(dataMap_);
  while (i.hasNext()) {
      i.next();
      delete i.value();
  }

  dataMap_.clear();

}

Jan Möbius's avatar
Jan Möbius committed
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854
/** Returns a flat, human readable representation of all comments. */
const QString BaseObject::getAllCommentsFlat() const {
    QStringList result;

    result.append(QString("BEGIN Comments for object \"%1\"").arg(name()));

    /*
     * Compose JSON parsable object.
     */
    QJsonObject comment_obj;
    for (QMap<QString, QString>::const_iterator it = commentsByKey_.begin(), it_end = commentsByKey_.end();
            it != it_end; ++it) {

        QJsonParseError json_error;
        QString test_json_str = QString::fromUtf8("{\"test\": %1}").arg(it.value());
        QByteArray test_json_ba = test_json_str.toUtf8();
        QJsonDocument test_json = QJsonDocument::fromJson(test_json_ba, &json_error);
        if (json_error.error != QJsonParseError::NoError) {
            comment_obj[it.key()] = it.value();
        } else {
            comment_obj[it.key()] = test_json.object().value("test");
        }
    }
    result.append(QString::fromUtf8(QJsonDocument(comment_obj).toJson(QJsonDocument::Indented)));

    result.append(QString("END Comments for object \"%1\"\n").arg(name()));

    return result.join("\n");
}


Jan Möbius's avatar
Jan Möbius committed
855 856
QMap<QString, PerObjectData*>& BaseObject::getPerObjectDataMap() {
  return dataMap_;
857 858 859
}


860
//=============================================================================