ProxyBase::ProxyBase( AbstractModel *belowModel, QObject *parent ) : QSortFilterProxyModel( parent ) , m_belowModel( belowModel ) { setSourceModel( m_belowModel->qaim() ); // Proxy the Playlist::AbstractModel signals. // If you need to do something special in a subclass, disconnect() this signal and // do your own connect() call. connect( sourceModel(), SIGNAL(activeTrackChanged(quint64)), this, SIGNAL(activeTrackChanged(quint64)) ); connect( sourceModel(), SIGNAL(queueChanged()), this, SIGNAL(queueChanged()) ); }
void DownloadManager::download(Track *track) { Q_EMIT progressChanged("0", "0", 0); m_timeoutTimer->start(); m_current = track; m_bBusy = true; m_NetError = QNetworkReply::NoError; Q_EMIT currentChanged(track); Q_EMIT queueChanged(m_queue.size()); m_nRequest.setUrl(track->url()); m_nReply = m_nManager->get(m_nRequest); connect(m_nReply, SIGNAL(readyRead()), this, SLOT(readyRead())); connect(m_nReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); connect(m_nReply, SIGNAL(finished()), this, SLOT(finished())); connect(m_nReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onNetworkError(QNetworkReply::NetworkError))); // Create&open file QString fileName = track->artist().trimmed() + " - " + track->title().trimmed() + ".mp3"; fileName.replace(QRegExp("[?*/\"<>]"), "_"); QDir::setCurrent(Settings::instance()->getValue("general/music_path").toString()); m_file.setFileName(fileName); m_file.open(QIODevice::WriteOnly); }
void SongQueue::queueUpdated() { if ( !pSettings->queueFilename.isEmpty() ) save(); emit queueChanged(); }
PlaylistQueueEditor::PlaylistQueueEditor() : QDialog(), m_blockViewUpdates( false ) { m_ui.setupUi( this ); updateView(); connect( The::playlist()->qaim(), SIGNAL( queueChanged() ), SLOT( queueChanged() ) ); m_ui.upButton->setIcon( KIcon( "go-up" ) ); m_ui.downButton->setIcon( KIcon( "go-down" ) ); m_ui.dequeueTrackButton->setIcon( KIcon( "list-remove" ) ); m_ui.clearButton->setIcon( KIcon( "edit-clear-list" ) ); connect( m_ui.upButton, SIGNAL( clicked() ), SLOT( moveUp() ) ); connect( m_ui.downButton, SIGNAL( clicked() ), SLOT( moveDown() ) ); connect( m_ui.clearButton, SIGNAL( clicked() ), SLOT( clear() ) ); connect( m_ui.dequeueTrackButton, SIGNAL( clicked() ), SLOT( dequeueTrack() ) ); connect( m_ui.buttonBox->buttons().first(), SIGNAL( clicked() ), SLOT( accept() ) ); }
void DownloadManager::add(Track *track) { if(m_queue.isEmpty() && !m_bBusy) { download(track); Q_EMIT started(); } else { m_queue.enqueue(track); Q_EMIT queueChanged(m_queue.size()); } }
void DownloadManager::onCancelAll() { if(m_bBusy) { m_queue.clear(); m_nReply->abort(); m_file.close(); m_file.remove(); Q_EMIT queueChanged(m_queue.size()); m_bBusy = false; } }
void TransactionQueue::emitQueueChanged() { QString tid; QStringList queued; if (m_activeTransaction) tid = m_activeTransaction->transactionId(); for (Transaction *trans : m_queue) queued << trans->transactionId(); emit queueChanged(tid, queued); }
void GlobalEventQueue::dequeue(EventItem* item) { Q_ASSERT(item); Q_ASSERT(ids_.contains(item->id())); if (!item || !ids_.contains(item->id())) return; ids_.removeAll(item->id()); items_.removeAll(item); Q_ASSERT(!ids_.contains(item->id())); emit queueChanged(); }
void GlobalEventQueue::enqueue(EventItem* item) { Q_ASSERT(item); Q_ASSERT(!ids_.contains(item->id())); if (!item || ids_.contains(item->id())) return; ids_.append(item->id()); items_.append(item); Q_ASSERT(ids_.contains(item->id())); emit queueChanged(); }
void ZAudioAdaptor::init(){ if(instance()){ connect(instance(), SIGNAL(bookmarkAdded(qint64)), this, SIGNAL(bookmarkAdded(qint64))); connect(instance(), SIGNAL(bufferChanged(int)), this, SIGNAL(bufferChanged(int))); connect(instance(), SIGNAL(buffering()), this, SIGNAL(buffering())); connect(instance(), SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64))); connect(instance(), SIGNAL(loading()), this, SIGNAL(loading())); connect(instance(), SIGNAL(paused()), this, SIGNAL(paused())); connect(instance(), SIGNAL(playing()), this, SIGNAL(playing())); connect(instance(), SIGNAL(positionChanged(double)), this, SIGNAL(positionChanged(double))); connect(instance(), SIGNAL(queueChanged()), this, SIGNAL(queueChanged())); connect(instance(), SIGNAL(queueCleared()), this, SIGNAL(queueCleared())); connect(instance(), SIGNAL(queuedSongChanged(int)), this, SIGNAL(queuedSongChanged(int))); connect(instance(), SIGNAL(reachedBookmark(qint64)), this, SIGNAL(reachedBookmark(qint64))); connect(instance(), SIGNAL(sourceChanged(QString)), this, SIGNAL(sourceChanged(QString))); connect(instance(), SIGNAL(stopped()), this, SIGNAL(stopped())); connect(instance(), SIGNAL(timeChanged(qint64)), this, SIGNAL(timeChanged(qint64))); } registerService(); }
YaEventNotifier::YaEventNotifier(QWidget* parent) : QWidget(parent) , psi_(0) { QVBoxLayout* vbox = new QVBoxLayout(this); vbox->setMargin(0); eventNotifierFrame_ = new YaEventNotifierFrame(this); vbox->addWidget(eventNotifierFrame_); connect(eventNotifierFrame_, SIGNAL(skip()), SLOT(skip())); connect(eventNotifierFrame_, SIGNAL(read()), SLOT(read())); connect(eventNotifierFrame_, SIGNAL(closeClicked()), SLOT(skipAll())); connect(GlobalEventQueue::instance(), SIGNAL(queueChanged()), SLOT(update()), Qt::QueuedConnection); update(); }
void CLastFm::addSongToQueue(QString title, QString artist, QString album) { myLastQueue[0] << artist; myLastQueue[1] << title; myLastQueue[2] << album; QDateTime tmpTime = QDateTime::currentDateTime(); QString tmpS; qint64 tmpI; tmpI = tmpTime.toTime_t(); tmpS.setNum(tmpI); myLastQueue[3] << tmpS; lastFmQueued = myLastQueue[0].size(); tmpS.setNum(lastFmQueued); emit queueChanged(lastFmQueued); if ( (db->getLastFmOnline()) && (getIsSessionOK()) ) { scrobbleSongs(); } }
void CLastFm::managerReply(QNetworkReply *pReply, QString mtd) { int size1, size2; size1 = methods.size(); size2 = bytearrays.size(); if (size1 != size2) qDebug() << "WARNING ! Queues have different sizes !"; else qDebug() << "BEGIN: Queue size is" << size1; if (size1 <= 0) return; QByteArray data=pReply->readAll(); QString content(data); qDebug() << "lastFm manager reply :" << content; emit lastReply(content); qDebug() << "URL was :" << pReply->url().toString(); // JEŚLI RESPONSE JEST OK, TO USUWAMY JUŻ TEN REQUEST if (content.contains("status=\"ok\"")) { if (!methods.isEmpty()) methods.removeFirst(); if (!bytearrays.isEmpty()) bytearrays.removeFirst(); } // ===================== // // auth.getMobileSession // // ===================== // if (mtd == "auth.getMobileSession") { qDebug() << "I got auth.getMobileSession response..."; if (content.contains("status=\"ok\"")) { QRegExp myRegExp(".+<key>"); content.remove(myRegExp); myRegExp = QRegExp("</key>.+"); content.remove(myRegExp); lastFmSessionKey = content; isSessionOK = true; } else { isSessionOK = false; if (content.contains("error code=\"4\"")) { qDebug() << "Check your last.fm user/pass"; emit errSignal("Check your last.fm user/pass"); } else if (content.contains("error code=\"11\"")) { qDebug() << "Last.fm is temporarily offline"; emit errSignal("Last.fm is temporarily offline"); } else { qDebug() << "Some strange error occured and I couldn't get lastFm session"; emit errSignal("I couldn't get last.fm session"); } } } // ====================== // // track.updateNowPlaying // // ====================== // else if (mtd == "track.updateNowPlaying") { qDebug() << "I got track.updateNowPlaying response..."; if (content.contains("status=\"ok\"")) { // } else { if (content.contains("error code=\"9\"")) { qDebug() << "Invalid session key, I'm re-authenticating..."; isSessionOK = false; getSession(); } else if (content.contains("error code=\"11\"")) { qDebug() << "Last.fm is temporarily offline"; emit errSignal("Last.fm is temporarily offline"); } else if (content.contains("error code=\"16\"")) { qDebug() << "Last.fm is temporarily unavailable"; emit errSignal("Last.fm is temporarily unavailable"); } else { qDebug() << "Some strange error occured and I couldn't updateNowPlaying"; emit errSignal("I couldn't update \"Now Playing\""); } } } // ========== // // track.love // // ========== // else if (mtd == "track.love") { qDebug() << "I got track.love response..."; if (content.contains("status=\"ok\"")) { if (!myLoveQueue[0].isEmpty()) { myLoveQueue[0].removeAt(0); myLoveQueue[1].removeAt(0); myLoveQueue[2].removeAt(0); } if (!myLoveQueue[0].isEmpty()) { loveSongs(); } } } // ============ // // track.unlove // // ============ // else if (mtd == "track.unlove") { qDebug() << "I got track.unlove response..."; if (content.contains("status=\"ok\"")) { if (!myUnloveQueue[0].isEmpty()) { myUnloveQueue[0].removeAt(0); myUnloveQueue[1].removeAt(0); myUnloveQueue[2].removeAt(0); } if (!myUnloveQueue[0].isEmpty()) { unloveSongs(); } } } // ============== // // track.scrobble // // ============== // else if (mtd == "track.scrobble") { qDebug() << "I got track.scrobble response..."; int oldSize = myLastQueue[0].size(); int newSize; if (content.contains("status=\"ok\"")) { if (myLastQueue[0].size() > 10) { for (int i = 0 ; i <= 9 ; i++) { myLastQueue[0].removeAt(0); myLastQueue[1].removeAt(0); myLastQueue[2].removeAt(0); myLastQueue[3].removeAt(0); } newSize = myLastQueue[0].size(); lastFmSent = lastFmSent + (oldSize - newSize); emit sentChanged(lastFmSent); lastFmQueued = lastFmQueued - (oldSize - newSize); emit queueChanged(lastFmQueued); scrobbleSongs(); } else { int tmpSize = myLastQueue[0].size(); for (int i = 0 ; i < tmpSize ; i++) { myLastQueue[0].removeAt(0); myLastQueue[1].removeAt(0); myLastQueue[2].removeAt(0); myLastQueue[3].removeAt(0); } emit ifSongIsPlayingUpdateNowPlaying(); newSize = myLastQueue[0].size(); lastFmSent = lastFmSent + (oldSize - newSize); emit sentChanged(lastFmSent); lastFmQueued = lastFmQueued - (oldSize - newSize); emit queueChanged(lastFmQueued); } } else qDebug() << "There was an error sending track(s) to Last.fm"; } // ==================== // // other Method name... // // ==================== // else { qDebug() << "Strange response, ignoring..."; } size1 = methods.size(); size2 = bytearrays.size(); if (size1 != size2) qDebug() << "WARNING ! Queues have different sizes !"; else qDebug() << "END: Queue size is" << size1; // if (size1 > 0) popMyQ(); }
Playlist::PrettyListView::PrettyListView( QWidget* parent ) : QListView( parent ) , ViewCommon() , m_headerPressIndex( QModelIndex() ) , m_mousePressInHeader( false ) , m_skipAutoScroll( false ) , m_firstScrollToActiveTrack( true ) , m_rowsInsertedScrollItem( 0 ) , m_showOnlyMatches( false ) , m_pd( 0 ) { // QAbstractItemView basics setModel( The::playlist()->qaim() ); m_prettyDelegate = new PrettyItemDelegate( this ); connect( m_prettyDelegate, SIGNAL( redrawRequested() ), this, SLOT( redrawActive() ) ); setItemDelegate( m_prettyDelegate ); setSelectionMode( ExtendedSelection ); setDragDropMode( DragDrop ); setDropIndicatorShown( false ); // we draw our own drop indicator setEditTriggers ( SelectedClicked | EditKeyPressed ); setAutoScroll( true ); setVerticalScrollMode( ScrollPerPixel ); setMouseTracking( true ); // Rendering adjustments setFrameShape( QFrame::NoFrame ); setAlternatingRowColors( true) ; The::paletteHandler()->updateItemView( this ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(newPalette(QPalette)) ); setAutoFillBackground( false ); // Signal connections connect( this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(trackActivated(QModelIndex)) ); connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotSelectionChanged()) ); connect( LayoutManager::instance(), SIGNAL(activeLayoutChanged()), this, SLOT(playlistLayoutChanged()) ); connect( model(), SIGNAL(activeTrackChanged(quint64)), this, SLOT(slotPlaylistActiveTrackChanged()) ); connect( model(), SIGNAL(queueChanged()), viewport(), SLOT(update()) ); // Warning, this one doesn't connect to the normal 'model()' (i.e. '->top()'), but to '->bottom()'. connect( Playlist::ModelStack::instance()->bottom(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(bottomModelRowsInserted(QModelIndex,int,int)) ); // Timers m_proxyUpdateTimer = new QTimer( this ); m_proxyUpdateTimer->setSingleShot( true ); connect( m_proxyUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProxyTimeout()) ); m_animationTimer = new QTimer(this); connect( m_animationTimer, SIGNAL(timeout()), this, SLOT(redrawActive()) ); m_animationTimer->setInterval( 250 ); playlistLayoutChanged(); // We do the following call here to be formally correct, but note: // - It happens to be redundant, because 'playlistLayoutChanged()' already schedules // another one, via a QTimer( 0 ). // - Both that one and this one don't work right (they scroll like 'PositionAtTop', // not 'PositionAtCenter'). This is probably because MainWindow changes its // geometry in a QTimer( 0 )? As a fix, MainWindow does a 'slotShowActiveTrack()' // at the end of its QTimer slot, which will finally scroll to the right spot. slotPlaylistActiveTrackChanged(); }
void QueueLabel::mousePressEvent( QMouseEvent* mouseEvent ) { hideToolTip(); if( m_timer.isActive() ) // if the user clicks again when (right after) the menu is open, { // (s)he probably wants to close it m_timer.stop(); return; } Playlist *pl = Playlist::instance(); PLItemList &queue = pl->m_nextTracks; if( queue.isEmpty() ) return; int length = 0; for( QPtrListIterator<PlaylistItem> it( queue ); *it; ++it ) { const int s = (*it)->length(); if( s > 0 ) length += s; } QPtrList<KPopupMenu> menus; menus.setAutoDelete( true ); KPopupMenu *menu = new KPopupMenu; menus.append( menu ); const uint count = queue.count(); if( length ) menu->insertTitle( i18n( "1 Queued Track (%1)", "%n Queued Tracks (%1)", count ) .arg( MetaBundle::prettyLength( length, true ) ) ); else menu->insertTitle( i18n( "1 Queued Track", "%n Queued Tracks", count ) ); Pana::actionCollection()->action( "queue_manager" )->plug( menu ); menu->insertItem( SmallIconSet( Pana::icon( "rewind" ) ), count > 1 ? i18n( "&Dequeue All Tracks" ) : i18n( "&Dequeue Track" ), 0 ); menu->insertSeparator(); uint i = 1; QPtrListIterator<PlaylistItem> it( queue ); it.toFirst(); while( i <= count ) { for( uint n = kMin( i + MAX_TO_SHOW - 1, count ); i <= n; ++i, ++it ) menu->insertItem( KStringHandler::rsqueeze( i18n( "%1. %2" ).arg( i ).arg( veryNiceTitle( *it ) ), 50 ), i ); if( i < count ) { menus.append( new KPopupMenu ); menu->insertSeparator(); menu->insertItem( i18n( "1 More Track", "%n More Tracks", count - i + 1 ), menus.getLast() ); menu = menus.getLast(); } } menu = menus.getFirst(); int mx, my; const int mw = menu->sizeHint().width(), mh = menu->sizeHint().height(), sy = mapFrom( Pana::StatusBar::instance(), QPoint( 0, 0 ) ).y(), sheight = Pana::StatusBar::instance()->height(); const QRect dr = QApplication::desktop()->availableGeometry( this ); if( mapYToGlobal( sy ) - mh > dr.y() ) my = mapYToGlobal( sy ) - mh; else if( mapYToGlobal( sy + sheight ) + mh < dr.y() + dr.height() ) my = mapYToGlobal( sy + sheight ); else my = mapToGlobal( mouseEvent->pos() ).y(); mx = mapXToGlobal( 0 ) - ( mw - width() ) / 2; int id = menu->exec( QPoint( mx, my ) ); if( id < 0 ) m_timer.start( 50, true ); else if( id == 0 ) //dequeue { const PLItemList dequeued = queue; while( !queue.isEmpty() ) pl->queue( queue.getLast(), true ); emit queueChanged( PLItemList(), dequeued ); } else { PlaylistItem *selected = queue.at( id - 1 ); if( selected ) pl->ensureItemCentered( selected ); } }
cQueue::cQueue(cInterface *_interface, const QString &_queueListFileName, const QString &_queueFolder, QObject *parent) : QObject(parent), mainInterface(_interface) { // initializes queue and create necessary files and folders queueListFileName = _queueListFileName; queueFolder = _queueFolder; if (!QFile::exists(queueFolder) && !CreateFolder(queueFolder)) { throw QString("cannot init queueListFileName folder to: " + queueFolder); } if (!QFile::exists(queueListFileName)) { QFile file(queueListFileName); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << "#\n# Mandelbulber queue file\n#\n"; file.close(); } else throw QString("cannot init queueListFileName to: " + queueListFileName); } // watch queue folder and the queue file in the filesystem queueFileWatcher.addPath(queueListFileName); queueFolderWatcher.addPath(queueFolder); QApplication::connect(&queueFileWatcher, SIGNAL(fileChanged(const QString &)), this, SLOT(queueFileChanged(const QString &))); QApplication::connect(&queueFolderWatcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(queueFolderChanged(const QString &))); UpdateListFromQueueFile(); UpdateListFromFileSystem(); image = new cImage(200, 200); if (mainInterface->mainWindow) { ui = mainInterface->mainWindow->ui; // Queue QApplication::connect(ui->pushButton_queue_add_current_settings, SIGNAL(clicked()), this, SLOT(slotQueueAddCurrentSettings())); QApplication::connect( ui->pushButton_queue_add_from_file, SIGNAL(clicked()), this, SLOT(slotQueueAddFromFile())); QApplication::connect( ui->pushButton_queue_add_orphaned, SIGNAL(clicked()), this, SLOT(slotQueueAddOrphaned())); QApplication::connect(ui->pushButton_queue_remove_orphaned, SIGNAL(clicked()), this, SLOT(slotQueueRemoveOrphaned())); QApplication::connect( ui->pushButton_queue_render_queue, SIGNAL(clicked()), this, SLOT(slotQueueRender())); QApplication::connect( ui->pushButton_queue_stop_rendering, SIGNAL(clicked()), this, SLOT(slotStopRequest())); QApplication::connect(ui->checkBox_show_queue_thumbnails, SIGNAL(stateChanged(int)), this, SLOT(slotShowQueueThumbsChanges(int))); QApplication::connect(this, SIGNAL(queueChanged()), this, SLOT(slotQueueListUpdate())); QApplication::connect(this, SIGNAL(queueChanged(int)), this, SLOT(slotQueueListUpdate(int))); QApplication::connect( this, SIGNAL(queueChanged(int, int)), this, SLOT(slotQueueListUpdate(int, int))); renderedImageWidget = new RenderedImage; renderedImageWidget->SetCursorVisibility(false); mainInterface->mainWindow->ui->verticalLayout_queue_preview->addWidget(renderedImageWidget); image->CreatePreview(1.0, 400, 300, renderedImageWidget); renderedImageWidget->setMinimumSize(image->GetPreviewWidth(), image->GetPreviewHeight()); renderedImageWidget->AssignImage(image); emit queueChanged(); }