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

void RosegardenGUIApp::setDocument ( RosegardenGUIDoc newDocument  )  [protected]

Set the current document

Do all the needed housework when the current document changes (like closing edit views, emitting documentChanged signal, etc...)

Definition at line 1462 of file rosegardengui.cpp.

References MultiViewCommandHistory::attachView(), RosegardenGUIDoc::clearModifiedStatus(), documentAboutToChange(), documentChanged(), RosegardenGUIDoc::getAutoSavePeriod(), RosegardenGUIDoc::getCommandHistory(), RosegardenGUIDoc::getComposition(), TrackEditor::getSegmentCanvas(), RosegardenGUIDoc::getStudio(), RosegardenGUIDoc::getTitle(), RosegardenGUIView::getTrackEditor(), initView(), m_doc, m_view, RosegardenGUIDoc::prepareAudio(), InstrumentParameterBox::setDocument(), RosegardenGUIDoc::setLoop(), slotDocumentModified(), TrackEditor::slotReadjustCanvasSize(), slotSetLoop(), slotSetPointerPosition(), slotTestClipboard(), slotUpdateMonitoring(), slotUpdatePlaybackPosition(), and RosegardenGUIDoc::syncDevices().

Referenced by mergeFile(), openFile(), RosegardenGUIApp(), slotFileClose(), and slotFileNew().

{
    if (m_doc == newDocument) return;

    emit documentAboutToChange();
    kapp->processEvents(); // to make sure all opened dialogs (mixer, midi devices...) are closed

    // Take care of all subparts which depend on the document

    // Caption
    //
    QString caption= kapp->caption();   
    setCaption(caption + ": " + newDocument->getTitle());

//     // reset AudioManagerDialog
//     //
//     delete m_audioManagerDialog; // TODO : replace this with a connection to documentAboutToChange() sig.
//     m_audioManagerDialog = 0;

    RosegardenGUIDoc* oldDoc = m_doc;

    m_doc = newDocument;

    if (m_seqManager) // when we're called at startup, the seq. man. isn't created yet
        m_seqManager->setDocument(m_doc);

    if (m_markerEditor) m_markerEditor->setDocument(m_doc);
    if (m_tempoView) { delete m_tempoView; m_tempoView = 0; }
    if (m_triggerSegmentManager) m_triggerSegmentManager->setDocument(m_doc);

    m_trackParameterBox->setDocument(m_doc);
    m_segmentParameterBox->setDocument(m_doc);
    m_instrumentParameterBox->setDocument(m_doc);

#ifdef HAVE_LIBLO
    if (m_pluginGUIManager) {
      m_pluginGUIManager->stopAllGUIs();
      m_pluginGUIManager->setStudio(&m_doc->getStudio());
    }
#endif

    if (getView() &&
      getView()->getTrackEditor() &&
      getView()->getTrackEditor()->getSegmentCanvas()) {
      getView()->getTrackEditor()->getSegmentCanvas()->endAudioPreviewGeneration();
    }

    // this will delete all edit views
    //
    delete oldDoc;
    
    // connect needed signals
    //
    connect(m_segmentParameterBox, SIGNAL(documentModified()),
            m_doc, SLOT(slotDocumentModified()));

    connect(m_doc, SIGNAL(pointerPositionChanged(Rosegarden::timeT)),
            this,   SLOT(slotSetPointerPosition(Rosegarden::timeT)));

    connect(m_doc, SIGNAL(pointerDraggedToPosition(Rosegarden::timeT)),
            this,   SLOT(slotSetPointerPosition(Rosegarden::timeT)));

    connect(m_doc, SIGNAL(documentModified(bool)),
            this,   SLOT(slotDocumentModified(bool)));

    connect(m_doc, SIGNAL(loopChanged(Rosegarden::timeT, Rosegarden::timeT)),
            this,  SLOT(slotSetLoop(Rosegarden::timeT, Rosegarden::timeT)));

    m_doc->getCommandHistory()->attachView(actionCollection());

    connect(m_doc->getCommandHistory(), SIGNAL(commandExecuted()),
            SLOT(update()));
    connect(m_doc->getCommandHistory(), SIGNAL(commandExecuted()),
            SLOT(slotTestClipboard()));

    // connect and start the autosave timer
    connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
    m_autoSaveTimer->start(m_doc->getAutoSavePeriod() * 1000);

    // Connect the playback timer
    //
    connect(m_playTimer, SIGNAL(timeout()), this, SLOT(slotUpdatePlaybackPosition()));
    connect(m_stopTimer, SIGNAL(timeout()), this, SLOT(slotUpdateMonitoring()));

    // finally recreate the main view
    //
    initView();

    connect(m_doc, SIGNAL(devicesResyncd()),
          this, SLOT(slotDocumentDevicesResyncd()));

    m_doc->syncDevices();
    m_doc->clearModifiedStatus();

    if (newDocument->getStudio().haveMidiDevices()) {
      stateChanged("got_midi_devices");
    } else {
      stateChanged("got_midi_devices", KXMLGUIClient::StateReverse);
    }

    // Ensure the sequencer knows about any audio files
    // we've loaded as part of the new Composition
    //
    m_doc->prepareAudio();

    // Do not reset instrument prog. changes after all.
//     if (m_seqManager)
//         m_seqManager->preparePlayback(true);

    Rosegarden::Composition &comp = m_doc->getComposition();

    // Set any loaded loop at the Composition and
    // on the marker on SegmentCanvas and clients
    //
    if (m_seqManager) m_doc->setLoop(comp.getLoopStart(), comp.getLoopEnd());

    emit documentChanged(m_doc);

    m_doc->clearModifiedStatus(); // because it's set as modified by the various
    // init operations
    // TODO: this sucks, have to sort it out somehow.

    // Readjust canvas size
    //
    m_view->getTrackEditor()->slotReadjustCanvasSize();

    m_stopTimer->start(100);
}


Generated by  Doxygen 1.6.0   Back to index