Example #1
0
WelcomeWidget::WelcomeWidget( QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::WelcomeWidget )
{
    ui->setupUi( this );

    ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
    WelcomePlaylistModel* model =  new WelcomePlaylistModel( this );
    ui->playlistWidget->setModel( model );
    ui->playlistWidget->overlay()->resize( 380, 86 );
    ui->tracksView->overlay()->setEnabled( false );

    connect( model,SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) );


    m_tracksModel = new PlaylistModel( ui->tracksView );
    ui->tracksView->setPlaylistModel( m_tracksModel );
    m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );

    m_timer = new QTimer( this );
    connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );

    connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );

    connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) );
    connect( AudioEngine::instance() ,SIGNAL( playlistChanged( PlaylistInterface* ) ), this, SLOT( updatePlaylists() ), Qt::QueuedConnection );
}
int Database::abortAllQueries()
{
  for( std::vector<Query*>::iterator it = m_runningQueries.begin();
       it != m_runningQueries.end();
       ++it)
  {
    (*it)->abort();
  }

  while (!m_runningQueries.empty())
  {
    checkQueries();
    msleep(100);
  }

  return 0;
}
void Database::poll()
{
  checkQueries();

  if (!m_connectionThread)
    return;

  Thread::EventData event;
  if (!m_connectionThread->getEvent(event))
    return;

  if (event.id == ConnectThread::CONNECTION_FINISHED)
  {
    if (m_connectionThread->wasSuccessful())
      runCallback("onConnected");
    else
      runCallback("onConnectionFailed", "s", m_connectionThread->error().c_str() );
  }
}