Esempio n. 1
0
void Engine::save() throw(PersistingException*)
{
    tracer->invoked(__func__);

    if (m_dirty) {
        tracer->sdebug(__func__) << "engine is dirty --> saving it..." << endl;

        // rename current file
        QDir path = m_fileAlbum->dirPath(true);
        QString oldFileName = m_fileAlbum->fileName();

        // create new filename
        QString basename = QFileInfo(oldFileName).baseName(true);
        QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz");
        QString newFileName = QString("%1-%2.%3").arg(basename).arg(timestamp).arg(Constants::FILE_EXTENSION);

        tracer->sdebug(__func__) << "backing up file in directory '" << path.absPath() << "': '" << oldFileName << "' --> '" << newFileName << "'..." << endl;

        if (!path.rename(oldFileName, newFileName, false)) {
            QString msg = QString("Could not move old file '%1/%2' to '%3/%4'. Not saving file. Use 'Save As'.").arg(path.absPath()).arg(oldFileName).arg(path.absPath()).arg(newFileName);
            throw new PersistingException(
                msg,
                ""
            );
        }

        // save
        XmlWriter writer = XmlWriter(*this);
        writer.store(new QFile(m_fileAlbum->absFilePath()));
    }

    m_dirty = false;
}
Esempio n. 2
0
void Engine::saveAs(QFileInfo& newFile) throw(PersistingException*)
{
    m_fileAlbum = new QFileInfo(newFile);
    m_uid = generateUid();

    // save
    XmlWriter writer = XmlWriter(*this);
    writer.store(new QFile(m_fileAlbum->absFilePath()));

    m_dirty = false;
}
Esempio n. 3
0
 virtual void StartTesting() {
     m_xml = XmlWriter( m_config.stream() );
     m_xml.startElement( "Catch" );
     if( !m_config.fullConfig()->name().empty() )
         m_xml.writeAttribute( "name", m_config.fullConfig()->name() );
 }