Logo Search packages:      
Sourcecode: ktechlab version File versions

void ItemView::createDragItem ( QDragEnterEvent *  event  )  [protected, inherited]

If the user drags an acceptable item in (e.g. a component in a circuit), then call this function to create the item and have it moved when the user moves his mouse while dragging.

Definition at line 410 of file itemview.cpp.

References ItemLibrary::createItem(), and ItemView::mousePosToCanvasPos().

Referenced by FlowCodeView::dragEnterEvent(), and CircuitView::dragEnterEvent().

      if ( !QString(e->format()).startsWith("ktechlab/") )
      QString text;
      QDataStream stream( e->encodedData(e->format()), IO_ReadOnly );
      stream >> text;

      QPoint p = mousePosToCanvasPos( e->pos() );
      m_pDragItem = itemLibrary()->createItem( text, p_itemDocument, true );
      if ( CNItem * cnItem = dynamic_cast<CNItem*>(m_pDragItem) )
            cnItem->move( snapToCanvas(p.x()), snapToCanvas(p.y()) );
      else m_pDragItem->move( p.x(), p.y() );

Generated by  Doxygen 1.6.0   Back to index