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

void CAMainWin::setMode ( CAMode  mode  )  [private]

Sets the current mode and updates the GUI and toolbars.

Todo:
Set other mouse cursors

Definition at line 1305 of file mainwin.cpp.

References _mode, _viewPortList, CAScoreViewPort::createTextEdit(), CAMusElement::musElementType(), CAScoreViewPort::playing(), CAScoreViewPort::removeTextEdit(), CAScoreViewPort::selection(), CAScoreViewPort::setBorder(), CAMusElementFactory::setMusElementType(), CAScoreViewPort::setShadowNoteVisible(), CAScoreViewPort::textEditVisible(), CAScoreViewPort::unsetBorder(), and updateToolBars().

Referenced by initViewPort(), and playbackFinished().

                                   {
      _mode = mode;

      switch (mode) {
            case SelectMode: {
                  for (int i=0; i<_viewPortList.size(); i++) {
                        if ( _viewPortList[i]->viewPortType()==CAViewPort::ScoreViewPort ) {
                              CAScoreViewPort *v = static_cast<CAScoreViewPort*>(_viewPortList[i]);
                              if ( !v->playing())
                                    v->unsetBorder();

                              v->setShadowNoteVisible(false);
                              if ( v->textEditVisible())
                                    v->removeTextEdit();
                        }
                  }

                  musElementFactory()->setMusElementType( CAMusElement::Undefined );
                  uiVoiceNum->setRealValue( 0 );

                  break;
            }
            case InsertMode: {
                  QPen p;
                  p.setColor(Qt::blue);
                  p.setWidth(3);

                  for (int i=0; i<_viewPortList.size(); i++) {
                        if ( _viewPortList[i]->viewPortType()==CAViewPort::ScoreViewPort ) {
                              CAScoreViewPort *v = static_cast<CAScoreViewPort*>(_viewPortList[i]);
                              if ( !v->playing())
                                    v->setBorder(p);
                        }
                  }

                  if ( currentScoreViewPort() ) {
                        currentScoreViewPort()->setShadowNoteVisible((musElementFactory()->musElementType() == CAMusElement::Note) ? true : false); /// \todo Set other mouse cursors
                        currentScoreViewPort()->repaint();
                  }

                  break;
            }
            case EditMode: {
                  QPen p;
                  p.setColor(Qt::red);
                  p.setWidth(3);

                  for (int i=0; i<_viewPortList.size(); i++) {
                        if (_viewPortList[i]->viewPortType()==CAViewPort::ScoreViewPort) {
                              CAScoreViewPort *sv = static_cast<CAScoreViewPort*>(_viewPortList[i]);
                              if (!sv->playing())
                                    (sv->setBorder(p));

                              sv->setShadowNoteVisible(false);
                              sv->repaint();
                        }
                  }

                  if (currentScoreViewPort() && currentScoreViewPort()->selection().size()) {
                        CAMusElement *elt = currentScoreViewPort()->selection().front()->musElement();
                        if ( elt->musElementType()==CAMusElement::Syllable ||
                             elt->musElementType()==CAMusElement::Mark && (static_cast<CAMark*>(elt)->markType()==CAMark::Text || static_cast<CAMark*>(elt)->markType()==CAMark::BookMark)
                        ) {
                              currentScoreViewPort()->createTextEdit(currentScoreViewPort()->selection().front());
                        } else {
                              currentScoreViewPort()->removeTextEdit();
                        }
                  }
            }
      }     // switch (mode)
      updateToolBars();
      if ( currentScoreViewPort() && !currentScoreViewPort()->textEditVisible() ||
           !currentScoreViewPort() && currentViewPort() )
            currentViewPort()->setFocus();
}


Generated by  Doxygen 1.6.0   Back to index