[vlmc-devel] commit: Media/Workspace: Rework the things a bit. ( 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:34:49 2010 +0200| [db94319c89c61fafd450b77550a5fc16f4790d75] | committer: Hugo Beauzée-Luyssen 

Media/Workspace: Rework the things a bit.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=db94319c89c61fafd450b77550a5fc16f4790d75
---

 src/Media/Media.cpp       |   14 +++++++-------
 src/Media/Media.h         |   16 +++++++++++-----
 src/Project/Workspace.cpp |   10 +++++++++-
 src/Project/Workspace.h   |    1 +
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index c847e0f..b809d1c 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -27,9 +27,11 @@
   */
 
 #include "Media.h"
+
+#include "Clip.h"
 #include "MetaDataManager.h"
 #include "VLCMedia.h"
-#include "Clip.h"
+#include "Workspace.h"
 
 #include <QtDebug>
 #include <QUrl>
@@ -271,12 +273,6 @@ Media::isInWorkspace() const
 }
 
 void
-Media::setInWorkspace(bool inWorkspace )
-{
-    m_inWorkspace = inWorkspace;
-}
-
-void
 Media::setFilePath( const QString &filePath )
 {
     delete m_fileInfo;
@@ -286,4 +282,8 @@ Media::setFilePath( const QString &filePath )
         m_mrl = "file:///" + QUrl::toPercentEncoding( filePath, "/" );
     else
         m_mrl = "fake:///" + QUrl::toPercentEncoding( filePath, "/" );
+    delete m_vlcMedia;
+    m_vlcMedia = new LibVLCpp::Media( m_mrl );
+    if ( Workspace::isInProjectDir( filePath ) == true )
+        m_inWorkspace = true;
 }
diff --git a/src/Media/Media.h b/src/Media/Media.h
index ffdb22a..8f366d2 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -75,6 +75,11 @@ public:
         File,
         Stream
     };
+    static const QString        VideoExtensions;
+    static const QString        AudioExtensions;
+    static const QString        ImageExtensions;
+    static const QString        streamPrefix;
+
     Media( const QString& filePath );
     virtual ~Media();
 
@@ -93,6 +98,11 @@ public:
     const QFileInfo             *fileInfo() const;
     const QString               &mrl() const;
     const QString               &fileName() const;
+    /**
+     *  \brief                  Set this media's path.
+     *
+     *  \param      path        The media path. This should be an absolute path.
+     */
     void                        setFilePath( const QString& path );
 
     /**
@@ -128,11 +138,8 @@ public:
     int                         nbVideoTracks() const;
 
     FileType                    fileType() const;
-    static const QString        VideoExtensions;
-    static const QString        AudioExtensions;
-    static const QString        ImageExtensions;
+
     InputType                   inputType() const;
-    static const QString        streamPrefix;
 
     void                        emitMetaDataComputed();
     void                        emitAudioSpectrumComuted();
@@ -148,7 +155,6 @@ public:
     void                        save( QXmlStreamWriter& project );
 
     bool                        isInWorkspace() const;
-    void                        setInWorkspace( bool inWorkspace );
 
 private:
     void                        setFileType();
diff --git a/src/Project/Workspace.cpp b/src/Project/Workspace.cpp
index ddaad52..dfac606 100644
--- a/src/Project/Workspace.cpp
+++ b/src/Project/Workspace.cpp
@@ -26,6 +26,7 @@
 #include "Library.h"
 #include "Media.h"
 #include "Project/WorkspaceWorker.h"
+#include "SettingsManager.h"
 
 #include <QtDebug>
 
@@ -67,5 +68,12 @@ void
 Workspace::copyTerminated( Media *media, QString dest )
 {
     media->setFilePath( dest );
-    media->setInWorkspace( true );
+}
+
+bool
+Workspace::isInProjectDir( const QString &filePath )
+{
+    const QString      projectDir = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
+
+    return ( filePath.startsWith( projectDir ) );
 }
diff --git a/src/Project/Workspace.h b/src/Project/Workspace.h
index 3e323e5..ea8a047 100644
--- a/src/Project/Workspace.h
+++ b/src/Project/Workspace.h
@@ -36,6 +36,7 @@ class Workspace : public QObject, public Singleton<Workspace>
     public:
         static const QString        workspacePrefix;
 
+        static bool                 isInProjectDir( const QString& filePath );
     private:
         Workspace();
         ~Workspace(){}



More information about the Vlmc-devel mailing list