SilentEye 0.4.1

sef/media.cpp

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye. If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #include "media.h"
00017 
00018 namespace SilentEyeFramework {
00019 
00020     Media::Media()
00021     {
00022         setObjectName("Media");
00023         m_type = UNKNOW;
00024         m_shortName = "unamed";
00025         m_filePath = "/home/";
00026         m_isLoaded = false;
00027     }
00028 
00029     Media::Media(const QString& filePath)
00030     {
00031         setObjectName("Media");
00032         m_type = UNKNOW;
00033         m_filePath = filePath;
00034         m_shortName = fileName(filePath);
00035         m_isLoaded = false;
00036     }
00037 
00038     Media::Media(const Media& md)
00039     {
00040         setObjectName("Media");
00041         m_type = UNKNOW;
00042         m_data = md.encodedData();
00043         m_shortName = md.shortName();
00044         m_filePath = md.filePath();
00045         m_isLoaded = false;
00046     }
00047 
00048     Media::Media(Media* md)
00049     {
00050         setObjectName("Media");
00051         m_type = UNKNOW;
00052         m_shortName = md->shortName();
00053         m_filePath = md->filePath();
00054         m_isLoaded = false;
00055     }
00056 
00057     Media::~Media()
00058     {
00059         // NOTHING TO DO
00060     }
00061 
00062     Media::Type Media::type() const {
00063         return m_type;
00064     }
00065 
00066     QPointer<EncodedData> Media::encodedData() const
00067     {
00068         return m_data;
00069     }
00070 
00071     void Media::setEncodedData(QPointer<EncodedData> data)
00072     {
00073         if(!m_data.isNull())
00074             delete m_data;
00075         m_data = data;
00076     }
00077 
00078     QString Media::shortName() const
00079     {
00080         return m_shortName;
00081     }
00082 
00083     void Media::setShortName(const QString shortName)
00084     {
00085         m_shortName = shortName;
00086     }
00087 
00088     QString Media::filePath() const
00089     {
00090         return m_filePath;
00091     }
00092 
00093     bool Media::isDataLoaded() const
00094     {
00095         return m_isLoaded;
00096     }
00097 
00098     quint32 Media::capacity() const
00099     {
00100         return 0;
00101     }
00102 
00103     bool Media::loadData()
00104     {
00105         return false;
00106     }
00107 
00108     bool Media::saveToDir(QString& outputDirPath)
00109     {
00110         Q_UNUSED(outputDirPath);
00111         return false;
00112     }
00113 
00114     QString Media::baseName() const
00115     {
00116         return QDir::fromNativeSeparators(m_filePath).section("/", 0, -2);
00117     }
00118 
00119     QString Media::fileName(QString filePath)
00120     {
00121         return QDir::fromNativeSeparators(filePath).section("/", -1, -1);
00122     }
00123 
00124     void Media::computeNewFileName(QString extension)
00125     {
00126         m_shortName = m_shortName.section('.', 0, -2)+"."+extension;
00127         m_filePath = baseName()+"/"+m_shortName;
00128     }
00129 
00130 }