Logo Search packages:      
Sourcecode: tellico version File versions

bool MainWindow::fileSaveAs (  ) 

Saves a document by a new filename

Returns:
Returns true if successful

Definition at line 1103 of file mainwindow.cpp.

References Tellico::EntryEditDialog::queryModified(), and slotStatusMsg().

Referenced by fileSave(), and slotFileSaveAs().

                            {
  if(!m_editDialog->queryModified()) {
    return false;
  }

  slotStatusMsg(i18n("Saving file with a new filename..."));

  QString filter = i18n("*.bc *.tc|Tellico files (*.tc)");
  filter += QString::fromLatin1("\n");
  filter += i18n("*|All files");

  // keyword 'open'
  KFileDialog dlg(QString::fromLatin1(":open"), filter, this, "filedialog", true);
  dlg.setCaption(i18n("Save As"));
  dlg.setOperationMode(KFileDialog::Saving);

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

  KURL url = dlg.selectedURL();

  if(url.fileName().contains('.') == 0) {
    QString cf = dlg.currentFilter();
    if(cf.length() > 1 && cf[1] == '.') {
      url.setFileName(url.fileName() + cf.mid(1));
    }
  }

  bool ret = true;

  if(!url.isEmpty() && url.isValid()) {
    kapp->setOverrideCursor(Qt::waitCursor);
    if(Kernel::self()->doc()->saveDocument(url)) {
      KRecentDocument::add(url);
      m_fileOpenRecent->addURL(url);
      setCaption(Kernel::self()->doc()->URL().fileName(), false);
      m_newDocument = false;
      m_fileSave->setEnabled(false);
    } else {
      ret = false;
    }
    kapp->restoreOverrideCursor();
  }

  slotStatusMsg(i18n(ready));
  return ret;
}


Generated by  Doxygen 1.6.0   Back to index