示例#1
0
bool BrowserNode::delete_internal(QString & warning) {
  if (deletedp())
    return TRUE;
  
  if (!is_writable() && !root_permission() && !is_from_lib()) {
    warning += "\n    " + TR("%1 is read-only", full_name());
    return FALSE;
  }
  
  static Q3PtrList<BrowserNode> targetof;
  static bool made = FALSE;
  bool made_here;
  
  if (!made) {
    made = TRUE;
    made_here = TRUE;
    referenced_by(targetof, TRUE);
  }
  else
    made_here = FALSE;
    
  bool ro = FALSE;
  
  if (!root_permission()) {
    Q3PtrListIterator<BrowserNode> it(targetof);
    BrowserNode * r;
    
    while ((r = it.current()) != 0) {
      if (!r->is_writable() && !r->is_from_lib()) {
	ro = TRUE;
	warning += "\n    ";
	switch (r->get_type()) {
	case UmlComponent:
	  warning += TR("%1 referenced by the read-only component %2", full_name(), r->full_name());
	  break;
	case UmlArtifact:
	  warning += TR("%1 referenced by the read-only artifact %2", full_name(), r->full_name());
	  break;
	default:
	  warning += TR("%1 is the target of the read-only relation %2", full_name(), r->full_name());
	  break;
	}
      }
      
      ++it;
    }
  }
  
  if (made_here) {
    made = FALSE;
    targetof.clear();
  }
  
  if (ro)
    return FALSE;
  
  // sub elts
  Q3ListViewItem * child;
  bool ok = TRUE;
  
  for (child = firstChild(); child != 0; child = child->nextSibling())
    ok &= ((BrowserNode *) child)->delete_internal(warning);
  
  if (ok) {
    is_deleted = TRUE;
    if (is_marked) {
      marked_list.removeRef(this);
      is_marked = FALSE;
    }
    get_data()->delete_it();
    repaint();
    package_modified();
  }

  return ok;
}