예제 #1
0
 foreach (PollingPlayerFactory* factory, m_polledFactories) {
     if (factory->exists()) {
         Player::Ptr player = factory->create();
         if (!player.isNull()) {
             m_players.insert(player);
             m_polledFactories.remove(factory);
             m_usedFactories.insert(factory);
             emit newPlayer(player);
         } else {
             kWarning() << "Failed to create a player";
         }
     }
 }
예제 #2
0
void PollingWatcher::addFactory(PollingPlayerFactory* factory)
{
    if (factory->exists()) {
        Player::Ptr player = factory->create();
        if (!player.isNull()) {
            m_players.insert(player);
            m_usedFactories.insert(factory);
            emit newPlayer(player);
        } else {
            kWarning() << "Failed to create a player";
            m_polledFactories.insert(factory);
        }
    } else {
        m_polledFactories.insert(factory);
    }

    if (!m_timer) {
        m_timer = new QTimer(this);
        m_timer->setInterval(5000);
        connect(m_timer, SIGNAL(timeout()), this, SLOT(checkPlayers()));
        m_timer->start();
    }
}