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

bool Rosegarden::RosegardenDocument::openDocument ( const QString &  filename,
bool  permanent = true,
bool  squelch = false,
const char *  format = 0 

Load the document by filename and format and emit the updateViews() signal. The "permanent" argument should be true if this document is intended to be loaded to the GUI for real editing work: in this case, any necessary device-synchronisation with the sequencer will be carried out. If permanent is false, the sequencer's device list will be left alone. If squelch is true, no progress dialog will be shown.

Definition at line 488 of file RosegardenDocument.cpp.


        case QMessageBox::Yes:

        case QMessageBox::No:
            return true;

        case QMessageBox::Cancel:
            return false;

    } else {

        UnusedAudioSelectionDialog *dialog =
            new UnusedAudioSelectionDialog
            (dynamic_cast<QWidget *>(parent()),
             tr("The following audio files were recorded during this session but have been unloaded\nfrom the audio file manager, and so are no longer in use in the document you are saving.\n\nYou may want to clean up these files to save disk space.\n\nPlease select any you wish to delete permanently from the hard disk.\n"),

        if (dialog->exec() != QDialog::Accepted) {
            delete dialog;
            return true;

        recordedOrphans = dialog->getSelectedAudioFileNames();
        delete dialog;

    if (recordedOrphans.empty())
        return true;

    QString question =
        tr("<qt>About to delete %n audio file(s) permanently from the hard disk.<br>There will be no way to recover the file(s).<br>Are you sure?</qt>", "", recordedOrphans.size());

    int reply = QMessageBox::warning(dynamic_cast<QWidget *>(parent()), "Warning", question, QMessageBox::Ok | QMessageBox::Cancel);

    if (reply == QMessageBox::Ok) {
        for (size_t i = 0; i < recordedOrphans.size(); ++i) {
            QFile file(recordedOrphans[i]);
            if (!file.remove()) {
                QMessageBox::critical(dynamic_cast<QWidget *>(parent()), tr("Rosegarden"), tr("File %1 could not be deleted.")

            QFile peakFile(QString("%1.pk").arg(recordedOrphans[i]));

    return true;

void RosegardenDocument::newDocument()
    if (m_clearCommandHistory) CommandHistory::getInstance()->clear();

void RosegardenDocument::performAutoload()
    QString autoloadFile = ResourceFinder().getAutoloadPath();

    QFileInfo autoloadFileInfo(autoloadFile);

    if (autoloadFile == "" || !autoloadFileInfo.isReadable()) {
        std::cerr << "WARNING: RosegardenDocument::performAutoload - "
                  << "can't find autoload file - defaulting" << std::endl;
        return ;

    bool permanent = true, squelch = true;
    openDocument(autoloadFile, permanent, squelch);

bool RosegardenDocument::openDocument(const QString& filename,
                                    bool permanent,
                                    bool squelch,
                                    const char* /*format*/ /*=0*/)
    RG_DEBUG << "RosegardenDocument::openDocument(" << filename << ")" << endl;

    if ( filename.isEmpty() )
        return false;


    QFileInfo fileInfo(filename);

    // Check if file readable with fileInfo ?
    if (!fileInfo.isReadable() || fileInfo.isDir()) {
        QString msg(tr("Can't open file '%1'").arg(filename));
        QMessageBox::warning(dynamic_cast<QWidget *>(parent()), tr("Rosegarden"), msg);
        return false;

    ProgressDialog *progressDlg = 0;
    if (!squelch) {
        progressDlg = new ProgressDialog(tr("Reading file..."),

        connect(progressDlg, SIGNAL(canceled()),
                &m_audioFileManager, SLOT(slotStopPreview()));


        progressDlg->setAutoReset(true); // we're re-using it for the preview generation


    QString errMsg;
    QString fileContents;
    bool cancelled = false;

    bool okay = GzipFile::readFromFile(filename, fileContents);
    if (!okay) errMsg = tr("Could not open Rosegarden file");

Generated by  Doxygen 1.6.0   Back to index