Save/Open Session - Implemented OssnFileFormat; code to build SessionContent still pending
This commit is contained in:
parent
c98104f078
commit
2a77f73e9c
@ -19,28 +19,73 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "ossnfileformat.h"
|
||||
|
||||
OssnFileFormat ossnFileFormat;
|
||||
|
||||
OssnFileFormat::OssnFileFormat()
|
||||
: SessionFileFormat(), NativeFileFormat()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
bool OssnFileFormat::open(const QString fileName,
|
||||
OstProto::SessionContent &session, QString &error)
|
||||
{
|
||||
// TODO
|
||||
OstProto::FileMeta meta;
|
||||
OstProto::FileContent content;
|
||||
bool ret = NativeFileFormat::open(fileName, meta, content, error);
|
||||
|
||||
if (!ret)
|
||||
goto _exit;
|
||||
|
||||
if (!content.matter().has_session())
|
||||
goto _missing_session;
|
||||
|
||||
postParseFixup(meta.data(), content);
|
||||
|
||||
session.CopyFrom(content.matter().streams());
|
||||
|
||||
return true;
|
||||
|
||||
_missing_session:
|
||||
error = QString(tr("%1 does not contain a session")).arg(fileName);
|
||||
goto _fail;
|
||||
_fail:
|
||||
qDebug("%s", error.toAscii().constData());
|
||||
_exit:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OssnFileFormat::save(const OstProto::SessionContent &session,
|
||||
const QString fileName, QString &error)
|
||||
{
|
||||
// TODO
|
||||
OstProto::FileContent content;
|
||||
|
||||
if (!session.IsInitialized())
|
||||
goto _session_not_init;
|
||||
|
||||
content.mutable_matter()->mutable_session()->CopyFrom(session);
|
||||
Q_ASSERT(content.IsInitialized());
|
||||
|
||||
return NativeFileFormat::save(OstProto::kSessionFileType, content,
|
||||
fileName, error);
|
||||
|
||||
_session_not_init:
|
||||
error = QString(tr("Internal Error: Session not initialized\n%1\n%2"))
|
||||
.arg(QString().fromStdString(
|
||||
session.InitializationErrorString()))
|
||||
.arg(QString().fromStdString(session.DebugString()));
|
||||
goto _fail;
|
||||
_fail:
|
||||
qDebug("%s", error.toAscii().constData());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OssnFileFormat::isMyFileFormat(const QString fileName)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
return isNativeFileFormat(fileName, OstProto::kSessionFileType);
|
||||
}
|
||||
|
||||
bool OssnFileFormat::isMyFileType(const QString fileType)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
return fileType.contains("(*.ossn)") ? true : false;
|
||||
}
|
||||
|
@ -20,11 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#ifndef _OSSN_FILE_FORMAT_H
|
||||
#define _OSSN_FILE_FORMAT_H
|
||||
|
||||
#include "nativefileformat.h"
|
||||
#include "sessionfileformat.h"
|
||||
|
||||
class OssnFileFormat : public SessionFileFormat
|
||||
class OssnFileFormat : public SessionFileFormat, public NativeFileFormat
|
||||
{
|
||||
public:
|
||||
OssnFileFormat();
|
||||
|
||||
virtual bool open(const QString fileName,
|
||||
OstProto::SessionContent &session, QString &error);
|
||||
virtual bool save(const OstProto::SessionContent &session,
|
||||
|
@ -48,7 +48,7 @@ QStringList SessionFileFormat::supportedFileTypes()
|
||||
<< "Ostinato Session (*.ossn)";
|
||||
}
|
||||
|
||||
void SessionFileFormat::openOffline(const QString fileName,
|
||||
void SessionFileFormat::openAsync(const QString fileName,
|
||||
OstProto::SessionContent &session, QString &error)
|
||||
{
|
||||
fileName_ = fileName;
|
||||
@ -60,7 +60,7 @@ void SessionFileFormat::openOffline(const QString fileName,
|
||||
start();
|
||||
}
|
||||
|
||||
void SessionFileFormat::saveOffline(
|
||||
void SessionFileFormat::saveAsync(
|
||||
const OstProto::SessionContent &session,
|
||||
const QString fileName, QString &error)
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ public:
|
||||
virtual QDialog* openOptionsDialog();
|
||||
virtual QDialog* saveOptionsDialog();
|
||||
|
||||
void openOffline(const QString fileName,
|
||||
void openAsync(const QString fileName,
|
||||
OstProto::SessionContent &session, QString &error);
|
||||
void saveOffline(const OstProto::SessionContent &session,
|
||||
void saveAsync(const OstProto::SessionContent &session,
|
||||
const QString fileName, QString &error);
|
||||
|
||||
bool result();
|
||||
|
Loading…
Reference in New Issue
Block a user