Logo Search packages:      
Sourcecode: bangarang version File versions  Download package

ListEngine * ListEngineFactory::availableListEngine ( const QString &  engine  )  [virtual]

Returns an available ListEngine for the specified engine`. ListEngineFactory factory will reuse ListEngines that are idle and create a new ListEngine if no idle ListEngines are available.

Parameters:
engine the engine (from the lri) for which a ListEngine should be returned.

Definition at line 110 of file listenginefactory.cpp.

References ListEngine::setModel().

Referenced by MediaItemModel::actionActivated(), MediaItemModel::categoryActivated(), MediaItemModel::load(), MediaItemModel::loadSources(), MediaItemModel::removeSourceInfo(), and MediaItemModel::updateSourceInfo().

{
    if (engine.toLower() == "music://") {
        //Search for available list engine
        bool foundListEngine = false;
        MusicListEngine * musicListEngine;
        for (int i = 0; i < m_musicListEngines.count(); ++i) {
            if (!m_musicListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                musicListEngine = m_musicListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            musicListEngine = new MusicListEngine(this);
            musicListEngine->setModel(m_parent);
            m_musicListEngines << musicListEngine;
        }
        return musicListEngine;           
    } else if (engine.toLower() == "files://") {
        //Search for available list engine
        bool foundListEngine = false;
        FileListEngine * fileListEngine;
        for (int i = 0; i < m_fileListEngines.count(); ++i) {
            if (!m_fileListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                fileListEngine = m_fileListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            fileListEngine = new FileListEngine(this);
            fileListEngine->setModel(m_parent);
            m_fileListEngines << fileListEngine;
        }
        return fileListEngine;        
    } else if (engine.toLower() == "video://") {
        //Search for available list engine
        bool foundListEngine = false;
        VideoListEngine * videoListEngine;
        for (int i = 0; i < m_videoListEngines.count(); ++i) {
            if (!m_videoListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                videoListEngine = m_videoListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            videoListEngine = new VideoListEngine(this);
            videoListEngine->setModel(m_parent);
            m_videoListEngines << videoListEngine;
        }
        return videoListEngine;        
    } else if (engine.toLower() == "cdaudio://") {
        //Search for available list engine
        bool foundListEngine = false;
        CDListEngine * cdListEngine;
        for (int i = 0; i < m_cdListEngines.count(); ++i) {
            if (!m_cdListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                cdListEngine = m_cdListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            cdListEngine = new CDListEngine(this);
            cdListEngine->setModel(m_parent);
            m_cdListEngines << cdListEngine;
        }
        return cdListEngine;        
    } else if (engine.toLower() == "dvdvideo://") {
        //Search for available list engine
        bool foundListEngine = false;
        DVDListEngine * dvdListEngine;
        for (int i = 0; i < m_dvdListEngines.count(); ++i) {
            if (!m_dvdListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                dvdListEngine = m_dvdListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            dvdListEngine = new DVDListEngine(this);
            dvdListEngine->setModel(m_parent);
            m_dvdListEngines << dvdListEngine;
        }
        return dvdListEngine;        
    } else if (engine.toLower() == "savedlists://") {
        //Search for available list engine
        bool foundListEngine = false;
        SavedListsEngine * savedListsEngine;
        for (int i = 0; i < m_savedListsEngines.count(); ++i) {
            if (!m_savedListsEngines.at(i)->isRunning()) {
                foundListEngine = true;
                savedListsEngine = m_savedListsEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            savedListsEngine = new SavedListsEngine(this);
            savedListsEngine->setModel(m_parent);
            m_savedListsEngines << savedListsEngine;
        }
        return savedListsEngine;        
    } else if (engine.toLower() == "medialists://") {
        //Search for available list engine
        bool foundListEngine = false;
        MediaListsEngine * mediaListsEngine;
        for (int i = 0; i < m_mediaListsEngines.count(); ++i) {
            if (!m_mediaListsEngines.at(i)->isRunning()) {
                foundListEngine = true;
                mediaListsEngine = m_mediaListsEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            mediaListsEngine = new MediaListsEngine(this);
            mediaListsEngine->setModel(m_parent);
            m_mediaListsEngines << mediaListsEngine;
        }
        return mediaListsEngine;        
    } else if (engine.toLower() == "audiostreams://") {
        //Search for available list engine
        bool foundListEngine = false;
        AudioStreamListEngine * audioStreamListEngine;
        for (int i = 0; i < m_audioStreamListEngines.count(); ++i) {
            if (!m_audioStreamListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                audioStreamListEngine = m_audioStreamListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            audioStreamListEngine = new AudioStreamListEngine(this);
            audioStreamListEngine->setModel(m_parent);
            m_audioStreamListEngines << audioStreamListEngine;
        }
        return audioStreamListEngine;        
    } else if (engine.toLower() == "semantics://") {
        //Search for available list engine
        bool foundListEngine = false;
        SemanticsListEngine * semanticsListEngine;
        for (int i = 0; i < m_semanticsListEngines.count(); ++i) {
            if (!m_semanticsListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                semanticsListEngine = m_semanticsListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            semanticsListEngine = new SemanticsListEngine(this);
            semanticsListEngine->setModel(m_parent);
            m_semanticsListEngines << semanticsListEngine;
        }
        return semanticsListEngine;        
    } else if (engine.toLower() == "cache://") {
        //Search for available list engine
        bool foundListEngine = false;
        CacheListEngine * cacheListEngine;
        for (int i = 0; i < m_cacheListEngines.count(); ++i) {
            if (!m_cacheListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                cacheListEngine = m_cacheListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            cacheListEngine = new CacheListEngine(this);
            cacheListEngine->setModel(m_parent);
            m_cacheListEngines << cacheListEngine;
        }
        return cacheListEngine;        
    } else if (engine.toLower() == "audioclips://") {
        //Search for available list engine
        bool foundListEngine = false;
        AudioClipsListEngine * audioClipsListEngine;
        for (int i = 0; i < m_audioClipsListEngines.count(); ++i) {
            if (!m_audioClipsListEngines.at(i)->isRunning()) {
                foundListEngine = true;
                audioClipsListEngine = m_audioClipsListEngines.at(i);
                break;
            }
        }
        if (!foundListEngine) {
            audioClipsListEngine = new AudioClipsListEngine(this);
            audioClipsListEngine->setModel(m_parent);
            m_audioClipsListEngines << audioClipsListEngine;
        }
        return audioClipsListEngine;        
    }
    return new ListEngine(this);
}


Generated by  Doxygen 1.6.0   Back to index