Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

bool FlowCodeDocument::isValidItem ( Item item  )  [protected, virtual]

Returns true if the CNItem is valid - e.g. will return true for a component in a circuit, but not in a pic program

Implements ICNDocument.

Definition at line 108 of file flowcodedocument.cpp.

References Item::id().

{
      if ( !dynamic_cast<FlowPart*>(item) && !dynamic_cast<DrawPart*>(item) )
            return false;
      
      if ( !item->id().startsWith("START") && !item->id().startsWith("PPEND") )
            return true;
      
      const ItemMap::iterator ciEnd = m_itemList.end();
      
      if ( item->id().startsWith("START") ) {
            int count = 0;
            
            for ( ItemMap::iterator it = m_itemList.begin(); it != ciEnd; ++it )
            {
                  if ( (*it)->id().startsWith("START") )
                        count++;
            }
            if ( count > 1 )
                  return false;
      } else if ( item->id().startsWith("PPEND") ) {
            int count = 0;
            for ( ItemMap::iterator it = m_itemList.begin(); it != ciEnd; ++it )
            {
                  if ( (*it)->id().startsWith("PPEND") )
                        count++;
            }

            if ( count > 1 )
                  return false;
      }
      
      return true;
}


Generated by  Doxygen 1.6.0   Back to index