Commit 004f936a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Workspace: Save the workspace path when saving a project.

parent db94319c
......@@ -255,7 +255,10 @@ void
Media::save( QXmlStreamWriter& project )
{
project.writeStartElement( "media" );
project.writeAttribute( "mrl", m_fileInfo->absoluteFilePath() );
if ( m_inWorkspace == true )
project.writeAttribute( "mrl", Workspace::workspacePrefix + m_workspacePath );
else
project.writeAttribute( "mrl", m_fileInfo->absoluteFilePath() );
project.writeEndElement();
}
......@@ -284,6 +287,10 @@ Media::setFilePath( const QString &filePath )
m_mrl = "fake:///" + QUrl::toPercentEncoding( filePath, "/" );
delete m_vlcMedia;
m_vlcMedia = new LibVLCpp::Media( m_mrl );
if ( Workspace::isInProjectDir( filePath ) == true )
//Don't call this before setting all the internals, as it relies on Media::fileInfo.
if ( Workspace::isInProjectDir( this ) == true )
{
m_inWorkspace = true;
m_workspacePath = Workspace::pathInProjectDir( this );
}
}
......@@ -178,6 +178,7 @@ protected:
int m_nbVideoTracks;
bool m_metadataComputed;
bool m_inWorkspace;
QString m_workspacePath;
signals:
void metaDataComputed( const Media* );
......
......@@ -71,9 +71,18 @@ Workspace::copyTerminated( Media *media, QString dest )
}
bool
Workspace::isInProjectDir( const QString &filePath )
Workspace::isInProjectDir( const Media *media )
{
const QString projectDir = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
return ( filePath.startsWith( projectDir ) );
return ( media->fileInfo()->absoluteFilePath().startsWith( projectDir ) );
}
QString
Workspace::pathInProjectDir( const Media *media )
{
const QString projectDir = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
return ( media->fileInfo()->absoluteFilePath().mid( projectDir.length() ) );
}
......@@ -36,7 +36,8 @@ class Workspace : public QObject, public Singleton<Workspace>
public:
static const QString workspacePrefix;
static bool isInProjectDir( const QString& filePath );
static bool isInProjectDir( const Media* media );
static QString pathInProjectDir( const Media* media );
private:
Workspace();
~Workspace(){}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment