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

void CircuitDocument::slotInitItemActions ( Item item = 0L  )  [virtual, slot]

Enables / disables / selects various actions depending on what is selected or not.

Parameters:
plugContextMenu If true, then will insert actions into contextmenu

Reimplemented from ItemDocument.

Definition at line 74 of file circuitdocument.cpp.

References View::action(), Document::activeView(), Component::angleDegrees(), Component::canRotate(), CNItemGroup::count(), ItemGroup::itemsAreSameType(), and ItemDocument::slotInitItemActions().

{
      ICNDocument::slotInitItemActions(itemBase);
      
      CircuitView * activeCircuitView = dynamic_cast<CircuitView*>(activeView());
      if ( !p_ktechlab || !activeCircuitView )
            return;
      
      Component * item = dynamic_cast<Component*>(itemBase);
      
      if ( !item && m_selectList->count() > 0 || !m_selectList->itemsAreSameType() )
            return;
      
      KAction * orientation_actions[] = {
            activeCircuitView->action("edit_orientation_0"),
            activeCircuitView->action("edit_orientation_90"),
            activeCircuitView->action("edit_orientation_180"),
            activeCircuitView->action("edit_orientation_270") };

      if ( !item || !item->canRotate() )
      {
            for ( unsigned i = 0; i < 4; ++i )
                  orientation_actions[i]->setEnabled(false);
            return;
      }

      for ( unsigned i = 0; i < 4; ++ i)
      {
            orientation_actions[i]->setEnabled(true);
            m_pOrientationAction->remove( orientation_actions[i] );
            m_pOrientationAction->insert( orientation_actions[i] );
      }
      
      if ( item->angleDegrees() == 0 )
            (static_cast<KToggleAction*>( orientation_actions[0] ))->setChecked(true);
      
      else if ( item->angleDegrees() == 90 )
            (static_cast<KToggleAction*>( orientation_actions[1] ))->setChecked(true);
      
      else if ( item->angleDegrees() == 180 )
            (static_cast<KToggleAction*>( orientation_actions[2] ))->setChecked(true);
      
      else if ( item->angleDegrees() == 270 )
            (static_cast<KToggleAction*>( orientation_actions[3] ))->setChecked(true);
}


Generated by  Doxygen 1.6.0   Back to index