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

void CAMainWin::on_uiImportDocument_triggered (  )  [private, slot]

Called when File->Import is clicked.

Definition at line 2938 of file mainwin.cpp.

References CASheet::contextCount(), handleUnsavedChanges(), CAPluginManager::importAction(), openDocument(), CAScoreViewPort::selectContext(), CADocument::sheetAt(), CADocument::sheetCount(), and updateToolBars().

                                              {
      if ( !handleUnsavedChanges() ) {
            return;
      }

      QStringList fileNames;
      int ffound = uiImportDialog->exec();
      if (ffound)
            fileNames = uiImportDialog->selectedFiles();

      if (!ffound)
            return;
      stopPlayback();

      QString s = fileNames[0];
      CADocument *oldDocument = document();

      bool success=false;
      if (CAPluginManager::importFilterExists(uiImportDialog->selectedFilter())) {
            setDocument(new CADocument());
            CACanorus::undo()->createUndoStack( document() );
            uiCloseDocument->setEnabled(true);

            CAPluginManager::importAction(uiImportDialog->selectedFilter(), document(), fileNames[0]);

            success=true;

            CACanorus::rebuildUI( document() );
      } else {
            CAImport *import=0;

            if ( uiImportDialog->selectedFilter() == CAFileFormats::MIDI_FILTER ) {
                  std::cout<<" Work in progress: midi import from file "<<s.toAscii().constData()<<std::endl;
                  import = new CAMidiImport();
            } else
            if ( uiImportDialog->selectedFilter() == CAFileFormats::MUSICXML_FILTER ) {
                  import = new CAMusicXmlImport();
            }

            if (import) {
                  import->setStreamFromFile( s );
                  import->importDocument();
                  import->wait();
                  success = (import->status()==0);
            }

            if (success) {
                  openDocument( import->importedDocument() );
            }
      }


      // select the first context automatically
      if ( document() && document()->sheetCount() && document()->sheetAt(0)->contextCount() ) {
            currentScoreViewPort()->selectContext( document()->sheetAt(0)->contextAt(0) );
      }

      updateToolBars();
}


Generated by  Doxygen 1.6.0   Back to index