Logo Search packages:      
Sourcecode: tellico version File versions

void MainWindow::slotFileExport ( int  format  )  [slot]

Exports the current document.

Parameters:
format The export format

Definition at line 1874 of file mainwindow.cpp.

References Tellico::ExportDialog::exportURL(), Tellico::ExportDialog::fileFilter(), and slotStatusMsg().

Referenced by initActions().

                                           {
  slotStatusMsg(i18n("Exporting data..."));

  Export::Format format = static_cast<Export::Format>(format_);
  ExportDialog dlg(format, Kernel::self()->collection(), this, "exportdialog");

  if(dlg.exec() == QDialog::Rejected) {
    slotStatusMsg(i18n(ready));
    return;
  }

  switch(ExportDialog::exportTarget(format)) {
    case Export::None:
      dlg.exportURL();
      break;

    case Export::Dir:
      kdDebug() << "MainWindow::slotFileExport() - ExportDir not implemented!" << endl;
      break;

    case Export::File:
    {
      KFileDialog fileDlg(QString::fromLatin1(":export"), dlg.fileFilter(), this, "filedialog", true);
      fileDlg.setCaption(i18n("Export As"));
      fileDlg.setOperationMode(KFileDialog::Saving);

      if(fileDlg.exec() == QDialog::Rejected) {
        slotStatusMsg(i18n(ready));
        return;
      }

      KURL url = fileDlg.selectedURL();

      // if the file has no extension, add it automatically, based on the current filter
      if(url.fileName().contains('.') == 0) {
        QString cf = fileDlg.currentFilter();
        if(cf.length() > 1 && cf[1] == '.') {
          url.setFileName(url.fileName() + cf.mid(1));
        }
      }

      if(!url.isEmpty()) {
        kapp->setOverrideCursor(Qt::waitCursor);
        dlg.exportURL(url);
        kapp->restoreOverrideCursor();
      }
    }
    break;
  }

  slotStatusMsg(i18n(ready));
}


Generated by  Doxygen 1.6.0   Back to index