Exemplo n.º 1
0
void SongQueue::clear()
{
    m_queue.clear();
    m_currentSong = 0;

    queueUpdated();
}
Exemplo n.º 2
0
bool SongQueue::next()
{
    if ( (int) m_currentSong >= m_queue.size() )
        return false;

    m_currentSong++;
    queueUpdated();
    return true;
}
Exemplo n.º 3
0
bool SongQueue::prev()
{
    if ( m_currentSong == 0  )
        return false;

    m_currentSong--;
    queueUpdated();
    return true;
}
Exemplo n.º 4
0
 bool TrackQueueModel::removeRows(int row, int count, const QModelIndex & parent )
 {
     if (row < 0 || row >= m_tracks.count() || count <= 0) return false;
     beginRemoveRows(parent, row, row + count - 1);
     for( int i = row+count-1; i >= row; --i )
     {
         Spotify::Track* track = m_tracks.takeAt(i);
         track->deleteLater();
     }
     endRemoveRows();
     emit queueUpdated();
     return true;
 }
Exemplo n.º 5
0
void AMBeamlineActionsListView::onActionAdded(int index){
	AMBeamlineActionItem *tmpItem = actionsList_->action(index);
	AMBeamlineActionItemView *tmpView = tmpItem->createView(index);
	if(!tmpView)
		return;
	actionsViewList_->insertItem(index, tmpItem->description(), tmpView, true);
	connect(tmpView, SIGNAL(removeRequested(AMBeamlineActionItem*)), this, SLOT(onActionRemoveRequested(AMBeamlineActionItem*)));
	connect(tmpView, SIGNAL(copyRequested(AMBeamlineActionItem*)), this, SIGNAL(copyRequested(AMBeamlineActionItem*)));
	connect(tmpView, SIGNAL(moveUpRequested(AMBeamlineActionItem*)), this, SIGNAL(moveUpRequested(AMBeamlineActionItem*)));
	connect(tmpView, SIGNAL(moveDownRequested(AMBeamlineActionItem*)), this, SIGNAL(moveDownRequested(AMBeamlineActionItem*)));

	reindexViews();
	emit queueUpdated(actionsQueue_->count());
}
Exemplo n.º 6
0
void SongQueue::statusChanged(int id, bool playstarted)
{
    // Find the file in queue - we go through the entire loop in case a file is added more than once
    for ( int i = 0; i < m_queue.size(); i++ )
    {
        if ( m_queue[i].id == id )
        {
            m_queue[i].state = playstarted ? Song::STATE_PLAYING : Song::STATE_READY;
            break;
        }
    }

    emit queueUpdated();
}
Exemplo n.º 7
0
void SessionListWidget::Update(SSHCredentials *sshCredentials, bool showFinished)
{
   QString cmd;
   SSHCommand *sshCmd = new SSHCommand(sshCredentials);
   connect(sshCmd, SIGNAL(completed(QString)), this, SLOT(queueUpdated(QString)));
   connect(sshCmd, SIGNAL(failed(QString)),    this, SLOT(commandFailed(QString)));

   if(showFinished) {
      cmd = QString("qselect -u %1 -x | xargs --no-run-if-empty qstat -fx");
   }
   else {
      cmd = QString("qselect -u %1 | xargs --no-run-if-empty qstat -f");
   }
   cmd = cmd.arg(sshCredentials->getUsername());
   sshCmd->Execute(cmd);
}
Exemplo n.º 8
0
 bool TrackQueueModel::setData(const QModelIndex &index, const QVariant &value, int role )
 {       
     if( !index.isValid() ) return false;
     if( role == Qt::UserRole )
     {
         if( qVariantCanConvert<Spotify::Track*>(value) )
         {
             Spotify::Track* track = value.value<Spotify::Track*>();
             Spotify::Track* copyTrack = new Spotify::Track( *track );
             m_tracks[ index.row() ] = copyTrack;
             emit dataChanged(index, index);
             emit queueUpdated();
         }
     }
     return false;
 }
Exemplo n.º 9
0
void SongQueue::processingFinished(const QString &origfile, bool succeed)
{
    Logger::debug( "Processing of file %s finished %s", qPrintable(origfile), succeed ? "successfully" : "with errors" );

    // Find the file in queue - we go through the entire loop in case a file is added more than once
    for ( int i = 0; i < m_queue.size(); i++ )
    {
        if ( m_queue[i].file == origfile )
        {
            if ( succeed )
                m_queue[i].state = Song::STATE_READY;
            else
                m_queue.removeAt( i );
        }
    }

    emit queueUpdated();
}
Exemplo n.º 10
0
void AMBeamlineActionsListView::onActionRemoved(int index){
	actionsViewList_->deleteItem(index);

	reindexViews();
	emit queueUpdated(actionsQueue_->count());
}
Exemplo n.º 11
0
void SongQueue::addSong( Song song )
{
    // Find the currnet singer index
    int singeridx = 0;

    if ( !m_queue.isEmpty() && (int) m_currentSong < m_queue.size() )
        singeridx = qMax( m_singers.indexOf( m_queue[m_currentSong].singer ), 0 );

    if ( m_singers.indexOf( song.singer ) == -1 )
    {
        if ( pSettings->queueAddNewSingersNext )
            m_singers.insert( singeridx + 1, song.singer );
        else
            m_singers.append( song.singer );
    }

    // Add to the end now
    song.id = m_nextQueueId++;

    // Find out if it needs to be converted
    song.state = KaraokeSong::needsProcessing( song.file ) ? Song::STATE_PREPARING : Song::STATE_READY;

    // If it is, schedule it for conversion
    if ( song.state == Song::STATE_PREPARING )
        pConverterMIDI->add( song.file );

    // Add to queue
    m_queue.append( song );

    // Now we have to rearrange the songs from current to the end according to the singer order
    singeridx++;

    if ( singeridx >= m_singers.size() )
        singeridx = 0;

    int songidx = m_currentSong + 1;
    Logger::debug( "Queue: Adding file %d %s by %s into queue: %s", song.songid, qPrintable(song.file), qPrintable(song.singer), qPrintable( song.stateText() ) );
/*
    for ( int i = 0; i < m_singers.size(); i++ )
        qDebug() << "Singer " << i << ": " << m_singers[i];

    for ( int i = 0; i < m_queue.size(); i++ )
        qDebug() << "Queue " << i << ": " << m_queue[i].file << " " << m_queue[i].singer;
*/
    while ( songidx < m_queue.size() )
    {
        // This song should be sung by singeridx
//        qDebug("%d: should be next singer %s", songidx, qPrintable( m_singers[singeridx] ));

        if ( m_queue[songidx].singer != m_singers[singeridx] )
        {
            // Find the song with this singer
            int i = songidx + 1;

            for ( ; i < m_queue.size(); i++ )
                if ( m_queue[i].singer == m_singers[singeridx] )
                    break;

            // Did we find a song with this singer?
            if ( i < m_queue.size() )
            {
                // Yes; swap with the current one, and move on
                m_queue.swap( songidx, i );
                songidx++;
            }
        }
        else
        {
            // This is already the case, so just skip this one
            songidx++;
        }

        // Switch to next singer
        singeridx++;

        if ( singeridx >= m_singers.size() )
            singeridx = 0;
    }

/*
    // Dump the queue
    qDebug() << "Queue after adding song" << file << "by" << singer;

    for ( int i = 0; i < m_queue.size(); i++ )
        qDebug() << "Queue " << i << ": " << m_queue[i].file << " " << m_queue[i].singer;
*/
    queueUpdated();
}