void SimilarArtistsApplet::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data ) { DEBUG_BLOCK QString artist = data[ "artist" ].toString(); if( source == "similarArtists" ) { setBusy( false ); if( !artist.isEmpty() ) { m_artist = artist; SimilarArtist::List list = data[ "similar" ].value<SimilarArtist::List>(); if( m_similars != list ) { m_similars = list; updateNavigationIcons(); artistsUpdate(); } } else { setHeaderText( i18n( "Similar Artists" ) ); m_scroll->clear(); m_scroll->hide(); setCollapseOn(); } } }
void PhotosApplet::stopped() { DEBUG_BLOCK setHeaderText( i18n( "Photos: No Track Playing" ) ); m_widget->clear(); m_widget->hide(); setBusy( false ); setMinimumHeight( m_header->height() ); setCollapseHeight( m_header->height() ); setCollapseOn(); updateConstraints(); }
void TabsApplet::updateInterface( const AppletState appletState ) { // return if state has not changed (except for init state) if( m_currentState == appletState && appletState != InitState ) return; debug() << "updating interface from state " << m_currentState << " to " << appletState; m_currentState = appletState; bool collapse = false; switch( m_currentState ) { case InitState: case StoppedState: m_reloadIcon.data()->setEnabled( false ); m_showTabBrowser = false; collapse = true; break; case NoTabsState: m_reloadIcon.data()->setEnabled( true ); m_showTabBrowser = false; collapse = true; break; case FetchingState: m_reloadIcon.data()->setEnabled( false ); m_showTabBrowser = false; break; case TabState: m_reloadIcon.data()->setEnabled( true ); m_showTabBrowser = true; break; } QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( layout() ); m_showTabBrowser ? lo->addItem( m_tabsView ) : lo->removeItem( m_tabsView ); m_showTabBrowser ? m_tabsView->show() : m_tabsView->hide(); collapse ? setCollapseOn() : setCollapseOff(); updateConstraints(); update(); }
void LabelsApplet::setStoppedState( bool stopped ) { if( stopped == m_stoppedstate ) return; m_stoppedstate = stopped; m_userLabels.clear(); m_webLabels.clear(); if( !stopped ) { m_reloadIcon.data()->setEnabled( true ); m_titleText = i18n( "Labels" ); m_addLabelProxy.data()->show(); m_addLabel.data()->show(); m_addLabel.data()->clearEditText(); // not needed at the moment, since setStoppedState(false) is only called in dataUpdated() and we know that the engine never sends state=started without the user labels; // so the minimum size is set in constraintsEvent() // setCollapseOffHeight( m_header->height() + m_addLabelProxy.data()->size().height() + 2 * standardPadding() ); // setCollapseOff(); } else { m_reloadIcon.data()->setEnabled( false ); m_titleText = i18n( "Labels: No track playing" ); m_addLabelProxy.data()->hide(); m_addLabel.data()->hide(); setBusy( false ); qDeleteAll( m_labelItems ); m_labelItems.clear(); qDeleteAll( m_labelAnimations ); m_labelAnimations.clear(); setMinimumHeight( collapseHeight() ); setCollapseOn(); } }
void PhotosApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) // SLOT { if( name != QLatin1String("photos") || data.isEmpty() ) return; QString text; if( data.contains( "message" ) ) { text = data["message"].toString(); if( text.contains( QLatin1String("Fetching") ) ) { debug() << "received message: Fetching"; setHeaderText( i18n( "Photos: %1", text ) ); setMinimumHeight( m_header->height() ); setCollapseHeight( m_header->height() ); setCollapseOn(); m_widget->clear(); m_widget->hide(); if( canAnimate() ) setBusy( true ); } else if( text.contains( QLatin1String("stopped") ) ) { debug() << "received message: stopped"; stopped(); } else { debug() << "received message:" << text; setHeaderText( i18n( "Photos: %1", text ) ); m_widget->hide(); setMinimumHeight( m_header->height() ); setCollapseHeight( m_header->height() ); setCollapseOn(); setBusy( false ); } } else if( data.contains( "data" ) ) { m_widget->clear(); m_currentArtist = text = data["artist"].toString(); PhotosInfo::List photos = data["data"].value< PhotosInfo::List >(); debug() << "received data for:" << text << photos.count(); setHeaderText( i18n( "Photos: %1", text ) ); if( photos.isEmpty() ) { setBusy( false ); setMinimumHeight( m_header->height() ); setCollapseHeight( m_header->height() ); setCollapseOn(); return; } setBusy( true ); m_widget->setPhotosInfoList( photos ); setMinimumHeight( 220 ); setCollapseOff(); m_widget->show(); layout()->invalidate(); } else { setMinimumHeight( m_header->height() ); setCollapseHeight( m_header->height() ); setCollapseOn(); m_widget->clear(); m_widget->hide(); setBusy( false ); } updateConstraints(); }
void Albums::dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ) { if( name != QLatin1String("albums") ) return; Meta::AlbumList albums = data[ "albums" ].value<Meta::AlbumList>(); Meta::TrackPtr track = data[ "currentTrack" ].value<Meta::TrackPtr>(); QString headerText = data[ "headerText" ].toString(); setHeaderText( headerText.isEmpty() ? i18n("Albums") : headerText ); //Don't keep showing the albums for the artist of the last track that had album in the collection if( (m_currentTrack == track) && (m_albums == albums) ) return; if( albums.isEmpty() ) { debug() << "received albums is empty"; setCollapseOn(); m_albums.clear(); m_albumsView->clear(); return; } setCollapseOff(); m_albums = albums; m_currentTrack = track; m_albumsView->clear(); m_albumsView->setMode( track ? AlbumsProxyModel::SortByYear : AlbumsProxyModel::SortByCreateDate ); QStandardItem *currentItem( 0 ); foreach( Meta::AlbumPtr albumPtr, albums ) { // do not show all tracks without an album from the collection, this takes ages // TODO: show all tracks from this artist that are not part of an album if( albumPtr->name().isEmpty() ) continue; Meta::TrackList tracks = albumPtr->tracks(); if( tracks.isEmpty() ) continue; AlbumItem *albumItem = new AlbumItem(); albumItem->setIconSize( 50 ); albumItem->setAlbum( albumPtr ); albumItem->setShowArtist( !m_currentTrack ); int numberOfDiscs = 0; int childRow = 0; qStableSort( tracks.begin(), tracks.end(), Meta::Track::lessThan ); QMultiHash< int, TrackItem* > trackItems; // hash of tracks items for each disc foreach( Meta::TrackPtr trackPtr, tracks ) { if( numberOfDiscs < trackPtr->discNumber() ) numberOfDiscs = trackPtr->discNumber(); TrackItem *trackItem = new TrackItem(); trackItem->setTrack( trackPtr ); // bold the current track to make it more visible if( m_currentTrack && *m_currentTrack == *trackPtr ) { currentItem = trackItem; trackItem->bold(); } // If compilation and same artist, then highlight, but only if there's a current track if( m_currentTrack && m_currentTrack->artist() && trackPtr->artist() && (*m_currentTrack->artist() == *trackPtr->artist()) && albumPtr->isCompilation() ) { trackItem->italicise(); } trackItems.insert( trackPtr->discNumber(), trackItem ); } for( int i = 0; i <= numberOfDiscs; ++i ) { QList<TrackItem*> items = trackItems.values( i ); if( !items.isEmpty() ) { const TrackItem *item = items.first(); QStandardItem *discItem( 0 ); if( numberOfDiscs > 1 ) { discItem = new QStandardItem( i18n("Disc %1", item->track()->discNumber()) ); albumItem->setChild( childRow++, discItem ); int discChildRow = 0; foreach( TrackItem *trackItem, items ) discItem->setChild( discChildRow++, trackItem ); } else { foreach( TrackItem *trackItem, items ) albumItem->setChild( childRow++, trackItem ); } } } m_albumsView->appendAlbum( albumItem ); } m_albumsView->sort(); if( currentItem ) { m_albumsView->setRecursiveExpanded( currentItem, true ); m_albumsView->scrollTo( currentItem ); } updateConstraints(); }