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

void MediaItemModel::categoryActivated ( QModelIndex  index  )  [slot]

Loads the list of MediaItems associated with "Category" mediaItem at the specified model index.

Parameters:
index QModelIndex of category. The url of the "Category" type MediaItem associated with the row of this index contains the lri representing the list of MediaItems to load. (This slot is useful for View ItemDelegates to tell the model to load the category when clicked.)

Definition at line 199 of file mediaitemmodel.cpp.

References ListEngineFactory::availableListEngine(), MediaListProperties::engine(), ListEngineFactory::engineExists(), ListEngineFactory::generateRequestSignature(), MediaListCache::isInCache(), MediaListProperties::lri, mediaListProperties(), MediaListProperties::name, ListEngine::setMediaListProperties(), and ListEngine::setRequestSignature().

{
    MediaListProperties mediaListProperties;
    mediaListProperties.lri =  itemFromIndex(index)->data(MediaItem::UrlRole).toString();
    mediaListProperties.name =  m_mediaList.at(index.row()).title;
    m_mediaListProperties = mediaListProperties;
    
    if (m_mediaListCache->isInCache(m_mediaListProperties.lri)) {
        removeRows(0, rowCount());
        setLoadingState(true);
        // Load data from from the cache
        ListEngine * listEngine = m_listEngineFactory->availableListEngine("cache://");
        MediaListProperties cacheListProperties;
        cacheListProperties.lri = QString("cache://dummyarg?%1").arg(m_mediaListProperties.lri);
        m_requestSignature = m_listEngineFactory->generateRequestSignature();
        listEngine->setRequestSignature(m_requestSignature);
        listEngine->setMediaListProperties(cacheListProperties);
        listEngine->start();
    } else {    
        if (m_listEngineFactory->engineExists(m_mediaListProperties.engine())) {
            removeRows(0, rowCount());
            setLoadingState(true);
            if (m_lrisLoading.indexOf(m_mediaListProperties.lri) == -1) {
                // Since this lri is not currently being loaded by any list engine
                // go ahead and start a new load
                ListEngine * listEngine = m_listEngineFactory->availableListEngine(m_mediaListProperties.engine());
                m_requestSignature = m_listEngineFactory->generateRequestSignature();
                listEngine->setRequestSignature(m_requestSignature);
                listEngine->setMediaListProperties(m_mediaListProperties);
                m_lriStartTimes.insert(m_mediaListProperties.lri, QTime::currentTime());
                m_lrisLoading.append(m_mediaListProperties.lri);
                listEngine->start();
                kDebug()<< "started load for " << m_mediaListProperties.lri;
            }
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index