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

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

Called when File->Export is clicked.

Definition at line 2871 of file mainwin.cpp.

References CAPluginManager::exportAction(), CAExport::exportDocument(), CAExport::setStreamToFile(), and CAExport::wait().

Referenced by on_uiExportToPdf_triggered().

                                              {
      QStringList fileNames;
      QString fileExtString;
      QStringList fileExtList;
      int ffound = uiExportDialog->exec();
      if (!ffound)
            return;

      // ! Warning: If there is still a running export instance
      // !               this will stop the old one (kill it actually)
      // @todo: maybe block new export until the old is finished
      if( _poExp ) // Delete old export instance
            delete _poExp;

      fileNames = uiExportDialog->selectedFiles();

      QString s = fileNames[0];
      if(s.isEmpty())
      {
            QMessageBox::information( 0,tr("No file name"), tr("Warning: No file name for export specified.") );
            return;
      }

      if (!s.contains('.')) {
            int left = uiExportDialog->selectedFilter().indexOf("(*.") + 2;
            int len = uiExportDialog->selectedFilter().size() - left - 1;
            fileExtString = uiExportDialog->selectedFilter().mid( left, len );
            // the default file extension is the first one:
            fileExtList = fileExtString.split( " " );
            s.append( fileExtList[0] );
      }

      if (CAPluginManager::exportFilterExists(uiExportDialog->selectedFilter())) {
            CAPluginManager::exportAction(uiExportDialog->selectedFilter(), document(), s);
      } else {
            if ( uiExportDialog->selectedFilter() == CAFileFormats::MIDI_FILTER ) {
                  CAMidiExport *pme = new CAMidiExport;
                  _poExp = pme;
            } else if ( uiExportDialog->selectedFilter() == CAFileFormats::LILYPOND_FILTER ) {
                  CALilyPondExport *ple = new CALilyPondExport;
                  _poExp = ple;
            } else if ( uiExportDialog->selectedFilter() == CAFileFormats::MUSICXML_FILTER ) {
                  CAMusicXmlExport *musicxml = new CAMusicXmlExport;
                  _poExp = musicxml;
            } else if ( uiExportDialog->selectedFilter() == CAFileFormats::PDF_FILTER ) {
                  CAPDFExport *ppe = new CAPDFExport;
                  _poExp = ppe;
            } else if ( uiExportDialog->selectedFilter() == CAFileFormats::SVG_FILTER ) {
                  CASVGExport *pse = new CASVGExport;
                  _poExp = pse;
            } else {
                  //TODO: unknown/unsupported format, raise an error
                  return;
            }
            if( _poExp )
            {
                  _poExp->setStreamToFile( s );
                  _poExp->exportDocument( document() );
                  _poExp->wait();
                  //delete _poExp;
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index