亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dynamicmode.cpp

?? Amarok是一款在LINUX或其他類UNIX操作系統中運行的音頻播放器軟件。 經過兩年開發后
?? CPP
字號:
/*************************************************************************** * copyright            : (C) 2005 Seb Ruiz <me@sebruiz.net>               * * copyright            : (C) 2006 Gábor Lehel <illissius@gmail.com>       * * copyright            : (C) 2006 Bonne Eggleston <b.eggleston@gmail.com  * **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#define DEBUG_PREFIX "DynamicMode"#include "collectiondb.h" // querybuilder, similar artists#include "debug.h"#include "enginecontroller.h" // HACK to get current artist for suggestion retrieval#include "mountpointmanager.h" // device ids#include "playlist.h"#include "playlistbrowser.h"#include "playlistbrowseritem.h"#include "playlistselection.h"#include "playlistwindow.h"#include "statusbar.h"#include "dynamicmode.h"#include <kapplication.h> // random func#include <qregexp.h>#include <qvaluevector.h>////////////////////////////////////////////////////////////////////////////////    CLASS DynamicMode////////////////////////////////////////////////////////////////////////////DynamicMode::DynamicMode( const QString &name )    : m_title( name )    , m_cycle( true )    , m_upcoming( 20 )    , m_previous( 5 )    , m_appendType( RANDOM ){}DynamicMode::~DynamicMode(){}voidDynamicMode::deleting(){    if( this == Playlist::instance()->dynamicMode() )        Playlist::instance()->disableDynamicMode();}voidDynamicMode::edit(){    if( this == Playlist::instance()->dynamicMode() )        Playlist::instance()->editActiveDynamicMode(); //so the changes get noticed    else        ConfigDynamic::editDynamicPlaylist( PlaylistWindow::self(), this );}QStringList DynamicMode::items()   const { return m_items; }QString DynamicMode::title()       const { return m_title; }bool DynamicMode::cycleTracks()   const { return m_cycle; }int  DynamicMode::upcomingCount() const { return m_upcoming; }int  DynamicMode::previousCount() const { return m_previous; }int  DynamicMode::appendType()    const { return m_appendType; }void DynamicMode::setItems( const QStringList &list ) { m_items = list;      }void DynamicMode::setCycleTracks( bool e )            { m_cycle = e;         }void DynamicMode::setUpcomingCount( int c )           { m_upcoming = c;      }void DynamicMode::setPreviousCount( int c )           { m_previous = c;      }void DynamicMode::setAppendType( int type )           { m_appendType = type; }void DynamicMode::setTitle( const QString& title )    { m_title = title;     }void DynamicMode::setDynamicItems( QPtrList<PlaylistBrowserEntry>& newList ){DEBUG_BLOCK    QStringList strListEntries;    PlaylistBrowserEntry* entry;    QPtrListIterator<PlaylistBrowserEntry> it( newList );    while( (entry = it.current()) != 0 )    {        ++it;        strListEntries << entry->text(0);    }    setItems( strListEntries );    PlaylistBrowser::instance()->saveDynamics();    rebuildCachedItemSet();}void DynamicMode::rebuildCachedItemSet(){DEBUG_BLOCK    m_cachedItemSet.clear();    if( appendType() == RANDOM || appendType() == SUGGESTION )    {        QueryBuilder qb;        qb.setOptions( QueryBuilder::optRandomize | QueryBuilder::optRemoveDuplicates );        qb.addReturnValue( QueryBuilder::tabSong, QueryBuilder::valURL );        if( appendType() == SUGGESTION )        {            // TODO some clever stuff here for spanning across artists            QString artist = EngineController::instance()->bundle().artist();            if( artist.isEmpty() )            {                PlaylistItem *currentItem = Playlist::instance()->currentItem();                if( currentItem != 0 )                    artist = currentItem->artist();            }            debug() << "seeding from: " << artist << endl;            QStringList suggestions = CollectionDB::instance()->similarArtists( artist, 16 );            // for this artist, choose 4 suggested artists at random, to get further suggestions from            QStringList newChosen;            for( uint suggestCount = 0; suggestCount < 4; ++suggestCount )            {                if( suggestions.isEmpty() )                    break;                QString chosen = suggestions[ KApplication::random() % suggestions.count() ];                debug() << "found similar artist: " << chosen << endl;                QStringList newSuggestions = CollectionDB::instance()->similarArtists( chosen, 10 );                for( uint c = 0; c < 4; ++c ) // choose another 4 artists                {                    if( newSuggestions.isEmpty() )                        break;                    QString s = newSuggestions[ KApplication::random() % newSuggestions.count() ];                    debug() << "found extended similar artist: " << s << endl;                    newChosen += s;                    newSuggestions.remove( s );                }                suggestions.remove( chosen );            }            if ( !newChosen.isEmpty() )                suggestions += newChosen;            qb.addMatches( QueryBuilder::tabArtist, suggestions );        }        qb.setLimit( 0, CACHE_SIZE );        debug() << "Using SQL: " << qb.query() << endl;        QStringList urls = qb.run();        foreach( urls ) //we have to run setPath on all raw paths        {            KURL current;            current.setPath( *it );            m_cachedItemSet += current;        }    }    else    {        PlaylistBrowser *pb = PlaylistBrowser::instance();        QPtrList<PlaylistBrowserEntry> dynamicEntries = pb->dynamicEntries();        if( !dynamicEntries.count() )        {            Amarok::StatusBar::instance()->longMessage( i18n( "This dynamic playlist has no sources set." ),                                                        KDE::StatusBar::Sorry );            return;        }        // Create an array of the sizes of each of the playlists        QValueVector<int> trackCount(dynamicEntries.count()) ;        int trackCountTotal = 0;        for( uint i=0; i < dynamicEntries.count(); i++ ){          trackCount[i] = 0;          if ( QListViewItem *item = dynamicEntries.at( i ) ){            if( item->rtti() == PlaylistEntry::RTTI )              trackCount[i] = static_cast<PlaylistEntry *>(item)->tracksURL().count();            else if( item->rtti() == SmartPlaylist::RTTI  )              trackCount[i] = static_cast<SmartPlaylist *>(item)->length();            trackCountTotal += trackCount[i];          }        }        PlaylistBrowserEntry* entry;        QPtrListIterator<PlaylistBrowserEntry> it( dynamicEntries );        //const int itemsPerSource = CACHE_SIZE / dynamicEntries.count() != 0 ? CACHE_SIZE / dynamicEntries.count() : 1;        int i = 0;        while( (entry = it.current()) != 0 )        {            ++it;            //trackCountTotal might be 0            int itemsForThisSource = trackCountTotal ? CACHE_SIZE * trackCount[i] / trackCountTotal : 1;            if (itemsForThisSource == 0)              itemsForThisSource = 1;             debug() << "this source will return " << itemsForThisSource << " entries" << endl;            if( entry->rtti() == PlaylistEntry::RTTI )            {                KURL::List t = tracksFromStaticPlaylist( static_cast<PlaylistEntry*>(entry), itemsForThisSource);                m_cachedItemSet += t;            }            else if( entry->rtti() == SmartPlaylist::RTTI )            {                KURL::List t = tracksFromSmartPlaylist( static_cast<SmartPlaylist*>(entry), itemsForThisSource);                m_cachedItemSet += t;            }            i++;        }    }}KURL::List DynamicMode::tracksFromStaticPlaylist( PlaylistEntry *item, uint songCount ){DEBUG_BLOCK    KURL::List trackList = item->tracksURL();    KURL::List returnList;    for( uint i=0; i < songCount; )    {        if( trackList.isEmpty() )            break;        KURL::List::Iterator urlIt = trackList.at( KApplication::random() % trackList.count() );        if( (*urlIt).isValid() )        {            returnList << (*urlIt).path();            ++i;        }        trackList.remove( urlIt );    }    debug() << "Returning " << returnList.count() << " tracks from " << item->text(0) << endl;    return returnList;}KURL::List DynamicMode::tracksFromSmartPlaylist( SmartPlaylist *item, uint songCount ){DEBUG_BLOCK    if( !item || !songCount )        return KURL::List();    bool useDirect = true;    const bool hasTimeOrder = item->isTimeOrdered();    debug() << "The smart playlist: " << item->text(0) << ", time order? " << hasTimeOrder << endl;    QString sql = item->query();    // FIXME: All this SQL magic out of collectiondb is not a good thing    // if there is no ordering, add random ordering    if ( sql.find( QString("ORDER BY"), false ) == -1 )    {        QRegExp limit( "(LIMIT.*)?;$" );        sql.replace( limit, QString(" ORDER BY %1 LIMIT %2 OFFSET 0;")                            .arg( CollectionDB::instance()->randomFunc() )                            .arg( songCount ) );    }    else    {        uint limit=0, offset=0;        QRegExp limitSearch( "LIMIT.*(\\d+).*OFFSET.*(\\d+)" );        int findLocation = limitSearch.search( sql, 0 );        if( findLocation == -1 ) //not found, let's find out the higher limit the hard way        {            QString counting( sql );            counting.replace( QRegExp( "SELECT.*FROM" ), "SELECT COUNT(*) FROM" );            // Postgres' grouping rule doesn't like the following clause            counting.replace( QRegExp( "ORDER BY.*" ), "" );            QStringList countingResult = CollectionDB::instance()->query( counting );            limit = countingResult[0].toInt();        }        else        {   // There's a Limit, we have to respect it.            // capturedTexts() gives us the strings that were matched by each subexpression            offset = limitSearch.capturedTexts()[2].toInt();            limit  = limitSearch.capturedTexts()[1].toInt();        }        // we must be ordering by some other arbitrary query.        // we can scrap it, since it won't affect our result        if( !hasTimeOrder )        {            // We can mess with the limits if the smart playlist is not orderd by a time criteria            // Why? We can have a smart playlist which is ordered by name or by some other quality which            // is meaningless in dynamic mode            QRegExp orderLimit( "(ORDER BY.*)?;$" );            sql.replace( orderLimit, QString(" ORDER BY %1 LIMIT %2 OFFSET 0;")                                        .arg( CollectionDB::instance()->randomFunc() )                                        .arg( songCount ) );        }        else // time ordered criteria, only mess with the limits        {            debug() << "time based criteria used!" << endl;            if ( limit <= songCount ) // The list is even smaller than the number of songs we want :-(                songCount = limit;            else                // Let's get a random limit, repecting the original one.                offset += KApplication::random() % (limit - songCount);            if( findLocation == -1 ) // there is no limit            {                QRegExp queryEnd( ";$" ); // find the end of the query an add a limit                sql.replace( queryEnd, QString(" LIMIT %1 OFFSET %2;" ).arg( songCount*5 ).arg( offset ) );                useDirect = false;            }            else // there is a limit, so find it and replace it                sql.replace( limitSearch, QString(" LIMIT %1 OFFSET %2;" ).arg( songCount ).arg( offset ) );        }    }    // only return the fields that we need    sql.replace( QRegExp( "SELECT.*FROM" ), "SELECT tags.url, tags.deviceid FROM" );    QStringList queryResult = CollectionDB::instance()->query( sql );    QStringList items;    debug() << "Smart Playlist: adding urls from query: " << sql << endl;    if ( !item->query().isEmpty() )        //We have to filter all the un-needed results from query( sql )        for( uint x=0; x < queryResult.count() ; x += 2 )            items << MountPointManager::instance()->getAbsolutePath( queryResult[x+1].toInt(), queryResult[x] );    else        items = queryResult;    KURL::List urls;    foreach( items ) //we have to run setPath on all raw paths    {        KURL tmp;        tmp.setPath( *it );        urls << tmp;    }    KURL::List addMe;    // we have to randomly select tracks from the returned query since we can't have    // ORDER BY RAND() for some statements    if( !useDirect )    {        for( uint i=0; i < songCount && urls.count(); i++ )        {            KURL::List::iterator newItem = urls.at( KApplication::random() % urls.count() );            addMe << (*newItem);            urls.remove( newItem );        }    }    useDirect ?            debug() << "Returning " << urls.count()  << " tracks from " << item->text(0) << endl:            debug() << "Returning " << addMe.count() << " tracks from " << item->text(0) << endl;    return useDirect ? urls : addMe;}KURL::List DynamicMode::retrieveTracks( const uint trackCount ){DEBUG_BLOCK    KURL::List retrieval;    // always rebuild with suggested mode since the artists will be changing    if( m_cachedItemSet.count() <= trackCount || appendType() == SUGGESTION )        rebuildCachedItemSet();    for( uint i=0; i < trackCount; i++ )    {        if( m_cachedItemSet.isEmpty() )            break;        const int pos = KApplication::random() % m_cachedItemSet.count();        KURL::List::iterator newItem = m_cachedItemSet.at( pos );        if( QFile::exists( (*newItem).path() ) )            retrieval << (*newItem);        m_cachedItemSet.remove( newItem );    }    return retrieval;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩国产一区二| 欧美在线一区二区三区| 97se亚洲国产综合在线| 欧美日本一道本| 国产精品美日韩| 久国产精品韩国三级视频| 91美女视频网站| 久久久国产精品不卡| 天天影视色香欲综合网老头| 成人免费视频一区二区| 欧美一级高清大全免费观看| 亚洲欧美一区二区三区久本道91| 久久99精品久久久久婷婷| 欧美在线观看你懂的| 中文字幕一区不卡| 国产精品一区二区在线播放| 51久久夜色精品国产麻豆| 亚洲一区二区三区视频在线播放| 粉嫩av一区二区三区| 精品国产亚洲在线| 日韩黄色小视频| 欧美理论片在线| 亚洲自拍偷拍网站| 色综合一个色综合| 亚洲色图制服丝袜| 91浏览器入口在线观看| 国产精品免费av| 不卡一区在线观看| 国产精品人成在线观看免费| 国产一区二区不卡老阿姨| 欧美大胆一级视频| 另类小说一区二区三区| 欧美一级欧美三级| 免费的成人av| 亚洲精品一区二区三区蜜桃下载| 人人精品人人爱| 日韩视频免费直播| 美女国产一区二区| 久久综合999| 福利一区在线观看| 中文字幕中文字幕在线一区 | 一区二区在线电影| 99麻豆久久久国产精品免费| 国产精品视频免费看| 成人午夜碰碰视频| 亚洲三级电影网站| 欧美视频一区二区三区在线观看 | 岛国精品一区二区| 国产精品免费av| 91成人国产精品| 国产麻豆91精品| 国产精品女同一区二区三区| 成人av电影在线| 一片黄亚洲嫩模| 欧美午夜免费电影| 激情五月婷婷综合| 欧美经典一区二区| 91精彩视频在线| 日韩不卡免费视频| 国产人妖乱国产精品人妖| 91在线观看下载| 日韩精品高清不卡| 日本一区二区三区在线不卡| 91麻豆高清视频| 免费成人在线视频观看| 中国色在线观看另类| 欧美亚日韩国产aⅴ精品中极品| 日本最新不卡在线| 国产日产欧美精品一区二区三区| 91视频91自| 狠狠色狠狠色综合日日91app| 亚洲欧洲精品一区二区精品久久久| 欧美系列日韩一区| 国产一区二区精品在线观看| 一区二区不卡在线播放| 久久综合九色综合97_久久久| 99久久精品免费精品国产| 日精品一区二区三区| 国产精品素人视频| 日韩一级大片在线| 色国产综合视频| 国产精品一卡二卡在线观看| 亚洲最快最全在线视频| 国产性色一区二区| 7777精品久久久大香线蕉| 不卡视频免费播放| 精品亚洲成a人在线观看| 亚洲一级二级三级| 综合婷婷亚洲小说| 久久久精品黄色| 日韩精品中文字幕在线不卡尤物| 色哟哟日韩精品| 不卡视频免费播放| 国产成人亚洲精品青草天美| 亚洲一区二区三区四区在线免费观看| 国产欧美一区二区精品性色| 91精品国产91久久久久久一区二区| 91麻豆精东视频| eeuss鲁片一区二区三区 | 国产传媒日韩欧美成人| 舔着乳尖日韩一区| 一区二区三区中文字幕在线观看| 国产精品入口麻豆原神| 久久精品视频在线免费观看 | 蜜臀av一区二区| 亚洲18色成人| 亚洲成人777| 亚洲午夜电影在线| 亚洲444eee在线观看| 亚洲午夜精品网| 亚洲午夜激情网页| 亚洲444eee在线观看| 亚洲午夜电影在线| 天堂久久久久va久久久久| 亚洲第一福利视频在线| 亚洲国产综合91精品麻豆| 亚洲影院理伦片| 亚洲123区在线观看| 天堂va蜜桃一区二区三区| 天天色天天操综合| 午夜精品久久久久久久99水蜜桃| 亚洲夂夂婷婷色拍ww47| 亚洲高清三级视频| 欧美a级一区二区| 国产乱子伦视频一区二区三区 | 国产日本一区二区| 欧美激情中文不卡| 亚洲视频你懂的| 亚洲一区二区成人在线观看| 午夜精品国产更新| 久久精品72免费观看| 国模一区二区三区白浆| 国产精品一品二品| 91亚洲国产成人精品一区二三 | 亚洲一区二区三区爽爽爽爽爽| 亚洲午夜一区二区| 久久国产尿小便嘘嘘| 高清国产午夜精品久久久久久| 91在线精品一区二区| 欧美日韩在线精品一区二区三区激情| 在线成人免费视频| 亚洲成人精品一区二区| 视频一区视频二区中文字幕| 久久精品国产一区二区| 国产精品亚洲第一区在线暖暖韩国| 国产99久久久国产精品| 欧美性生活影院| 日韩三级高清在线| 一区在线观看视频| 琪琪久久久久日韩精品| 成人国产精品免费观看| 欧美二区三区91| 欧美激情在线一区二区| 亚洲国产综合视频在线观看| 黄色成人免费在线| 欧美伊人久久大香线蕉综合69 | 日韩精品一二三区| 国产精品一区在线观看乱码| 色天天综合色天天久久| 日韩欧美黄色影院| 亚洲精品日产精品乱码不卡| 裸体健美xxxx欧美裸体表演| a在线欧美一区| 精品1区2区在线观看| 亚洲六月丁香色婷婷综合久久| 久草这里只有精品视频| 欧美揉bbbbb揉bbbbb| 国产精品私人影院| 久久99久久久久| 精品视频一区二区三区免费| 国产精品欧美极品| 久久国产人妖系列| 欧美日韩aaaaa| 亚洲欧美日韩国产手机在线| 国产一区在线观看视频| 欧美美女bb生活片| 亚洲精品伦理在线| 成人午夜激情片| 精品国精品自拍自在线| 香蕉av福利精品导航 | 国产中文字幕精品| 欧美妇女性影城| 亚洲国产wwwccc36天堂| 97久久精品人人爽人人爽蜜臀| 久久久激情视频| 国内欧美视频一区二区| 日韩色在线观看| 青青草精品视频| 日韩手机在线导航| 喷白浆一区二区| 日韩欧美成人一区| 欧美a级一区二区| 日韩欧美一级二级三级久久久| 亚洲线精品一区二区三区| 一本色道久久综合精品竹菊| 国产日本亚洲高清| 成人国产亚洲欧美成人综合网| 国产日韩欧美麻豆| 国产成人av影院| 欧美极品美女视频|