[vlmc-devel] commit: Workspace: Save the workspace path when saving a project. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sun Jun 20 23:50:33 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Jun 20 22:46:46 2010 +0200| [004f936ab0459f37841d369235e105209be29c29] | committer: Hugo Beauzée-Luyssen
Workspace: Save the workspace path when saving a project.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=004f936ab0459f37841d369235e105209be29c29
---
src/Media/Media.cpp | 11 +++++++++--
src/Media/Media.h | 1 +
src/Project/Workspace.cpp | 13 +++++++++++--
src/Project/Workspace.h | 3 ++-
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index b809d1c..9dd627d 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -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 );
+ }
}
diff --git a/src/Media/Media.h b/src/Media/Media.h
index 8f366d2..3afc186 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -178,6 +178,7 @@ protected:
int m_nbVideoTracks;
bool m_metadataComputed;
bool m_inWorkspace;
+ QString m_workspacePath;
signals:
void metaDataComputed( const Media* );
diff --git a/src/Project/Workspace.cpp b/src/Project/Workspace.cpp
index dfac606..126617b 100644
--- a/src/Project/Workspace.cpp
+++ b/src/Project/Workspace.cpp
@@ -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() ) );
+}
+
diff --git a/src/Project/Workspace.h b/src/Project/Workspace.h
index ea8a047..994237a 100644
--- a/src/Project/Workspace.h
+++ b/src/Project/Workspace.h
@@ -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(){}
More information about the Vlmc-devel
mailing list