Logo Search packages:      
Sourcecode: tellico version File versions

void MainWindow::importFile ( int  format,
const KURL &  url 
)

Used by main() to import file from command line.

Parameters:
format The file format
url The url

Definition at line 683 of file mainwindow.cpp.

References slotEnableModifiedActions(), slotEnableOpenedActions(), slotEntryCount(), and slotStatusMsg().

                                                         {
  // try to open document
  kapp->setOverrideCursor(Qt::waitCursor);

  Data::Collection* coll = 0;
  if(!url_.isEmpty() && url_.isValid() &&
#if KDE_IS_VERSION(3,1,90)
    KIO::NetAccess::exists(url_, true, this)
#else
    KIO::NetAccess::exists(url_, true)
#endif
    ) {
    coll = ImportDialog::importURL(static_cast<Import::Format>(format_), url_);
  } else {
    kapp->restoreOverrideCursor();
    KMessageBox::sorry(this, i18n(errorLoad).arg(url_.fileName()));
  }

  if(coll) {
    // this is rather dumb, but I'm too lazy to find the bug
    // if the document isn't initialized, then Tellico crashes
    // since Document::replaceCollection() ends up calling lots of stuff that isn't initialized
    if(!m_initialized) {
      Controller::self()->slotCollectionAdded(Kernel::self()->collection());
    }
    Kernel::self()->doc()->replaceCollection(coll);
    m_fileOpenRecent->setCurrentItem(-1);
    m_newDocument = true;
    slotEnableOpenedActions();
    slotEnableModifiedActions(false);
    kapp->restoreOverrideCursor();
  } else if(!m_initialized) {
    // special case on startup when openURL() is called with a command line argument
    // and that URL can't be opened. The window still needs to be initialized
    // the doc object is created with an initial book collection, continue with that
    Controller::self()->slotCollectionAdded(Kernel::self()->collection());
    m_fileSave->setEnabled(false);
    slotEnableOpenedActions();
    slotEnableModifiedActions(false);
    slotEntryCount();
  }
  m_initialized = true;
  slotStatusMsg(i18n(ready));
}


Generated by  Doxygen 1.6.0   Back to index