diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c83246dcb..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "thirdparty/jreen"] - path = thirdparty/jreen - url = git://github.com/euroelessar/jreen.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f1ca859c9..9693d6962 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,9 @@ SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) +# make predefined install dirs available everywhere +INCLUDE(GNUInstallDirs) + # installer creation INCLUDE( TomahawkCPack.cmake ) @@ -111,6 +114,13 @@ macro_log_feature(LIBATTICA_FOUND "libattica" "Provides support for automatic fe macro_optional_find_package(QuaZip) macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers automatically." "http://quazip.sourceforge.net/" FALSE "" "") +macro_optional_find_package(Jreen) +macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/euroelessar/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin.\n") + +macro_optional_find_package(QTweetLib) +macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n") + + IF( NOT QuaZip_FOUND ) add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip ) SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libtomahawk/thirdparty/quazip ) @@ -130,29 +140,17 @@ ENDIF() set(LIBLASTFM_FOUND true) #### submodules start +# automatically init submodules here, don't delete this code we may add submodules again # this installs headers and such and should really be handled in a separate package by packagers -IF( INTERNAL_JREEN ) - IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules) - EXECUTE_PROCESS(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - EXECUTE_PROCESS(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules) -ENDIF() -IF( INTERNAL_JREEN ) - ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/jreen ) - SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include ) - SET( LIBJREEN_LIBRARY jreen ) - SET( LIBJREEN_LIBRARIES ${LIBJREEN_LIBRARY} ) - SET( LIBJREEN_FOUND true ) - MESSAGE(STATUS "INTERNAL libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}") -ELSE( INTERNAL_JREEN ) - macro_optional_find_package(Jreen) -ENDIF( INTERNAL_JREEN ) -macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/euroelessar/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin. \n\n Use -DINTERNAL_JREEN=ON to build the git submodule inside Tomahawk \n Be aware this installs a full jreen with headers and everything!\n") +# IF( FALSE ) +# IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules) +# EXECUTE_PROCESS(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +# EXECUTE_PROCESS(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +# ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules) +# ENDIF() -macro_optional_find_package(QTweetLib) -macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n") #### submodules end ### libportfwd diff --git a/lang/tomahawk_es.ts b/lang/tomahawk_es.ts index 2435cd3bf..d73227cb4 100644 --- a/lang/tomahawk_es.ts +++ b/lang/tomahawk_es.ts @@ -4,82 +4,77 @@ ActionCollection - &Listen Along &Escuchar juntos - &Stop Listening Along - &Detener la reproducción conjunta + &Detener la reproducción conjunta - &Load Playlist &Cargar lista de reproducción - &Rename Playlist &Renombrar lista de reproducción - &Copy Playlist Link &Copiar enlace de lista de reproducción - &Play &Reproducir - &Stop &Detener - &Previous Track &Pista anterior - &Next Track &Pista siguiente - &Quit &Salir + + Stop &Listening Along + Detener la &reproducción conjunta + + + &Listen Privately + &Escuchar en privado + + + &Listen Publicly + &Escuchar públicamente + AlbumInfoWidget - Form Form - Other Albums by Artist Otros álbumes por el artista - - Click to show Super Collection Tracks Mostrar pistas de la Súper Colección - - Click to show Official Tracks - Mostrar pistas oficiales + Mostrar Pistas Oficiales - Other Albums by %1 Otros álbumes por %1 @@ -87,143 +82,138 @@ AlbumModel - Album Álbum - - All albums from %1 Todos los álbumes de %1 - All albums Todos los álbumes + + AlbumView + + After you have scanned your music collection you will find your latest album additions right here. + Tras haber escaneado su colección aquí encontrará los últimos álbumes añadidos. + + + This collection doesn't have any recent albums. + Esta colección no tiene álbumes recientes. + + ArtistInfoWidget - Form Form - Top Hits Grandes éxitos - Related Artists Artistas relacionados - Albums Álbumes - - Click to show All Releases - Mostrar todos los lanzamientos + Mostrar todos los lanzamientos - Click to show Official Releases Mostrar lanzamientos oficiales + + Click to show Super Collection Albums + Mostrar álbumes de la Super Colección + ArtistView - Sorry, your filter '%1' did not match any results. Tu filtro '%1' no reportó ningún resultado. + + After you have scanned your music collection you will find your tracks right here. + Tras haber escaneado su colección aquí encontrará las últimas pistas añadidas. + + + This collection is currently empty. + Esta colección está vacía. + AudioControls - Form - Form + Form - Prev Anterior - Play Reproducir - Pause Pausar - Next Siguiente - TextLabel - TextLabel + TextLabel - Artist Artista - Album Álbum - Owner Propietario - love favorita - Time Duración - Time Left Tiempo restante - Shuffle Aleatorio - Repeat Repetir - Low Bajar volumen - High Subir volumen @@ -231,36 +221,29 @@ AudioEngine - Tomahawk is playing "%1" by %2%3. Tomahawk está reproduciendo "%1" de %2%3. - on album %1 en el álbum %1 + + Tomahawk is stopped. + Tomahawk está parado. + CategoryAddItem - - New Playlist Nueva lista de reproducción - - - - New Station Nueva estación - - - %1 Station %1 estación @@ -268,12 +251,10 @@ CategoryItem - Playlists Listas de reproducción - Stations Estaciones @@ -281,7 +262,6 @@ ClearButton - Clear Limpiar @@ -289,12 +269,10 @@ CollectionFlatModel - My Collection Mi colección - Collection of %1 Colección de %1 @@ -302,33 +280,27 @@ CollectionItem - Top Loved Tracks Pistas favoritas - Loved Tracks - Pistas que me gustan + Pistas favoritas - Dashboard Es díficil la traducción de 'Dashboard', pero Escritorio me parece mejor que otras posibles traducciones como Tablero de mandos o Panel. Escritorio - Charts Listas de éxitos - New Additions Añadido recientemente - Super Collection Súper Colección @@ -336,7 +308,6 @@ CollectionView - This collection is empty. Esta colección está vacía. @@ -344,18 +315,14 @@ ContextWidget - InfoBar InfoBar - - Show Footnotes Mostrar información de contexto - Hide Footnotes Ocultar información de contexto @@ -363,43 +330,34 @@ CrashReporter - Tomahawk Crash Reporter Reportador de fallos de Tomahawk - <p><b>Sorry!</b>&nbsp;Tomahawk crashed. Information about the crash is now being sent to Tomahawk HQ so that we can fix the bug.</p> <p><b>¡Ups!</b>&nbsp;Tomahawk ha fallado. La información acerca del fallo se enviará a Tomahawk HQ para que podamos solucionar el error.</p> - Abort Abortar - You can disable sending crash reports in the configuration dialog. Puede desactivar el envío de informes de error en el diálogo de configuración. - Uploaded %L1 of %L2 KB. Subidos %L1 of %L2 KBs. - - Close Cerrar - Sent! <b>Many thanks</b>. ¡Enviado!<b>Muchas gracias</b>. - Failed to send crash info. Error al enviar la información del fallo. @@ -407,7 +365,6 @@ DatabaseCommand_AllAlbums - Unknown Desconocido @@ -415,17 +372,14 @@ DiagnosticsDialog - Tomahawk Diagnostics Diagnósticos de Tomahawk - Update Actualizar - Copy to Clipboard Copiar al portapapeles @@ -433,49 +387,38 @@ GetNewStuffDelegate - Installed Instalado - - Installing Instalando - - Failed Fallo - Uninstalling Desinstalando - Install Instalar - Upgrading Actualizando - Uninstall Desinstalar - Upgrade Actualizar - %1 downloads %1 descargas @@ -483,7 +426,6 @@ GetNewStuffDialog - Download New Resolvers Descargar nuevos resolvedores @@ -491,7 +433,6 @@ GlobalSearchWidget - Form Form @@ -499,27 +440,22 @@ GoogleWrapper - Configure this Google Account Configurar la cuenta Google - Google Address Dirección de Google - Enter your Google login to connect with your friends using Tomahawk! ¡Introduzca sus datos de inicio de sesión de Google para conectar con sus amigos que usen Tomahawk! - Add Friend Añadir amigo - Enter Google Address: Introduzca su dirección Google: @@ -527,25 +463,18 @@ InfoBar - InfoBar Barra de información - - - - TextLabel - TextLabel + TextLabel - Automatically update Actualizar automáticamente - Filter... Filtro... @@ -553,57 +482,46 @@ JabberConfig - Jabber Configuration Configuración de Jabber - Configure this Jabber account Configurar esta cuenta de Jabber - Enter your Jabber login to connect with your friends using Tomahawk! ¡Introduzca sus datos de inicio de sesión de Jabber para conectar con sus amigos que usen Tomahawk! - Login Information Información de login - Jabber ID: Jabeer ID: - e.g. user@example.com p. ej. usuario@ejemplo.com - Password: Contraseña: - An account with this name already exists! ¡Ya existe una cuenta con ese nombre! - Advanced Jabber Settings Configuración avanzada de Jabber - Server: Servidor: - Port: Puerto: @@ -611,87 +529,70 @@ JabberPlugin - User Interaction Interacción del usuario - Host is unknown El host es desconocido - Item not found Objeto no encontrado - Authorization Error Error de autorización - Remote Stream Error Error de flujo remoto - Remote Connection failed Conexión remota fallida - Internal Server Error Error interno del servidor - System shutdown Apagado del sistema - Conflict Conflicto - Unknown Desconocido - Add Friend Añadir amigo - Enter Jabber ID: Introduzca el ID de Jabber: - Add Friend... Añadir amigo... - XML Console... Consola XML... - I'm sorry -- I'm just an automatic presence used by Tomahawk Player (http://gettomahawk.com). If you are getting this message, the person you are trying to reach is probably not signed on, so please try again later! Lo siento -- Sólo soy una presencia automática usada por el reproductor Tomahawk (http://gettomahawk.com). Si está obteniendo este mensaje, la persona a la que intenta encontrar probablemente esté desconectada, ¡así que inténtelo de nuevo más tarde! - Authorize User Autorizar usuario - Do you want to grant <b>%1</b> access to your Collection? ¿Quiere permitir <b>%1</b> el acceso a tu colección? @@ -699,17 +600,14 @@ JobStatusView - Searching For Buscando por - Pending Pendiente - Idle Ocupado @@ -717,7 +615,6 @@ LastfmContext - Last.fm Last.fm @@ -725,7 +622,6 @@ LatchedStatusItem - %1 is listening along to you! ¡%1 está escuchando junto a usted! @@ -733,27 +629,22 @@ LoadXSPF - Load XSPF Cargar XSPF - Playlist Url URL de la lista de reproducción - Enter URL... Introducir URL... - ... ... - Automatically update Actualizar automáticamente @@ -761,20 +652,21 @@ LoadXSPFDialog - Load XSPF File Cargar archivo XSPF + + XSPF Files (*.xspf) + Archivos XSPF (*.xspf) + LocalCollection - Bookmarks Favoritos - Saved tracks Pistas guardadas @@ -782,50 +674,52 @@ NewPlaylistWidget - Enter a title for the new playlist: Introduzca un nombre para la nueva lista de reproducción: - Tomahawk offers a variety of ways to help you create playlists and find music you enjoy! ¡Tomahawk le ofrece varias maneras para ayudarle a crear listas de reproducción y encontrar la música que le guste! - Just enter a genre or tag name and Tomahawk will suggest a few songs to get you started with your new playlist: Introduzca un género o tag y Tomahawk le sugerirá unas cuantas canciones para comenzar su nueva lista de reproducción: - &Create Playlist &Crear lista de reproducción - Create a new playlist Crear una nueva lista de reproducción + + PlaylistItemDelegate + + played %1 by you + %1 reproducido por usted + + + played %1 by %2 + %1 reproducido por %2 + + PlaylistModel - A playlist by %1, created %2 Una lista de reproducción de %1, creada %2 - you - ti + usted - All tracks by %1 on album %2 Todas las pistas de %1 en el álbum %2 - All tracks by %1 Todas las pistas de %1 @@ -833,37 +727,30 @@ PlaylistTypeSelectorDlg - New Playlist Nueva lista de reproducción - Just a regular old playlist... Give it a name, drag in some tracks, and go! Sólo una lista de reproducción normal... ¡Póngale un nombre, añada algunas pistas, y comience! - Don't know exactly what you want? Give Tomahawk a few pointers and let it build a playlist for you! ¿No sabe exactamente lo que desea? ¡Dele a Tomahawk algunas indicaciones y déjele construir una lista de reproducción para usted! - Name: Nombre: - New Playlist... Nueva lista de reproducción... - Create Manual Playlist Crear lista de reproducción manual - Create Automatic Playlist Crear lista de reproducción automática @@ -871,70 +758,57 @@ PlaylistView - This playlist is currently empty. Add some tracks to it and enjoy the music! - Esta lista de reproducción está vacía. ¡Añádale algunas pistas y disfrute de la música! + Esta lista de reproducción está vacía. ¡Añada algunas pistas y disfrute de la música! ProxyDialog - Proxy Settings Configuración del proxy - Hostname of proxy server Hostname del servidor proxy - Host Host - Port Puerto - Proxy login Proxy login - User Usuario - Password Contraseña - Proxy password Contraseña del proxy - Type Tipo - No Proxy Hosts: No hosts proxy: - localhost *.example.com (space separated) localhost *.ejemplo.com (separados por espacios) - Use proxy for DNS lookups? ¿Usar proxy para búsquedas DNS? @@ -942,75 +816,139 @@ QObject - ago - atrás + atrás - %1 years%2 - %1 años%2 + %1 años%2 - %1 year%2 - %1 año%2 + %1 año%2 - %1 months%2 - %1 meses%2 + %1 meses%2 - %1 month%2 - %1 mes%2 + %1 mes%2 - %1 weeks%2 - %1 semanas%2 + %1 semanas%2 - %1 week%2 - %1 semana%2 + %1 semana%2 - %1 days%2 - %1 días%2 + %1 días%2 - %1 day%2 - %1 día%2 + %1 día%2 - %1 hours%2 - %1 horas%2 + %1 horas%2 - %1 hour%2 - %1 hora%2 + %1 hora%2 - %1 minutes%2 - %1 minutos%2 + %1 minutos%2 - just now justo ahora + + %n year(s) ago + + hace %n año + hace%n años + + + + %n year(s) + + %n año + %n años + + + + %n month(s) ago + + hace %n mes + hace %n meses + + + + %n month(s) + + %n mes + %n meses + + + + %n week(s) ago + + hace %n semana + hace %n semanas + + + + %n week(s) + + %n semana + %n semanas + + + + %n day(s) ago + + hace %n día + hace %n días + + + + %n day(s) + + %n día + %n días + + + + %n hour(s) ago + + hace %n hora + hace %n horas + + + + %n hour(s) + + %n hora + %n horas + + + + %1 minutes ago + hace %1 minutos + + + %1 minutes + %1 minutos + QuaZipFilePrivate - ZIP/UNZIP API error %1 ZIP/UNZIP API error %1 @@ -1018,22 +956,18 @@ QueueView - InfoBar InfoBar - Open Queue Abrir cola - Show Queue Mostrar cola - Hide Queue Ocultar cola @@ -1041,7 +975,6 @@ RelatedArtistsContext - Related Artists Artistas relacionados @@ -1049,12 +982,10 @@ ResolverConfigDelegate - Not found: %1 No encontrado: %1 - Failed to load: %1 Fallo al cargar: %1 @@ -1062,7 +993,6 @@ SearchLineEdit - Search Buscar @@ -1070,12 +1000,10 @@ SearchWidget - Search: %1 Buscar: %1 - Results for '%1' Resultados para '%1' @@ -1083,19 +1011,17 @@ Servent - Incoming Connection Attempt - Intento de conexión entrante + Intento de conexión entrante - Another Tomahawk instance is attempting to connect to you. Select whether to allow or deny this connection. Peer name: %1 Peer ID: %2 Remember: Only allow peers to connect if you have the legal right for them to stream music from you. - Otra instancia de Tomahawk está intentando conectarse a usted. Seleccione si autorizar o denegar ésta conexión. + Otra instancia de Tomahawk está intentando conectarse a usted. Seleccione si autorizar o denegar ésta conexión. Nombre del peer: %1 Peer ID: %2 @@ -1103,94 +1029,84 @@ Peer ID: %2 Recuerde: Sólo acéptelo si tiene el derecho legal para que escuchen música de usted. - Deny - Denegar + Denegar - Always Deny - Denegar siempre + Denegar siempre - Allow - Permitir + Permitir - Always Allow - Permitir siempre + Permitir siempre SettingsDialog - Accounts Cuentas - Collection Colección - Last.fm Last.fm - Resolvers Resolvedores - Advanced Avanzado - - Failed Error - Success Éxito - Could not contact server No se puede contactar con el servidor - Load script resolver file Cargar script de resolvedor - Delete Account Borrar cuenta + + Information + Información + + + Changing this setting requires a restart of Tomahawk! + ¡Cambiar esta configuración requiere el reinicio de Tomahawk! + SipConfigDelegate - Online - En línea + Conectado - Connecting... Conectando... - Offline Desconectado @@ -1198,34 +1114,37 @@ Recuerde: Sólo acéptelo si tiene el derecho legal para que escuchen música de SipHandler - Legal Warning Advertencia legal - By pressing OK below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemnify the Tomahawk developers and project from liability should you choose to break those laws. For more information, please see http://gettomahawk.com/legal - Si acepta este diálogo, está de acuerdo con que su uso de Tomahawk irá en concordancia con cualquier ley aplicable, incluyendo copyright y leyes de propiedad intelectual efectivas en su país de residencia, y acepta indemnizar a los desarrolladores de Tomahawk en el caso que rompa las leyes. + Si acepta este diálogo, está de acuerdo con que su uso de Tomahawk irá en concordancia con cualquier ley aplicable, incluyendo copyright y leyes de propiedad intelectual efectivas en su país de residencia, y acepta indemnizar a los desarrolladores de Tomahawk en el caso que rompa las leyes. Para más información, por favor visite http://gettomahawk.com/legal - I Do Not Agree Rechazar - I Agree Aceptar + + By pressing I Agree below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemnify the Tomahawk developers and project from liability should you choose to break those laws. + +For more information, please see http://gettomahawk.com/legal + Si acepta este diálogo, estará de acuerdo con que su uso de Tomahawk irá en concordancia con cualquier ley aplicable, incluyendo copyright y leyes de propiedad intelectual efectivas en su país de residencia, y acepta indemnizar a los desarrolladores de Tomahawk y al proyectoen el caso que rompa las leyes. + +Para más información, por favor visite http://gettomahawk.com/legal + SipModel - Add New Account... Añadir nueva cuenta... @@ -1233,93 +1152,77 @@ Para más información, por favor visite http://gettomahawk.com/legal SocialPlaylistWidget - Popular New Albums From Your Friends Nuevos álbumes favoritos de tus amigos - Most Played Playlists Listas de reproducción más reproducidas - Most Played Tracks You Don't Have - Pistas más reproducidas que no tiene + Que no tiene/No son suyas + Pistas más reproducidas no disponibles SourceDelegate - Track Pista - Album Álbum - Artist Artista - Local Local - Top 10 Top 10 - Offline Desconectado - All available tracks Todas las pistas disponibles - Online - En línea + Conectado SourceInfoWidget - Recent Albums Álbumes recientes - Latest Additions Añadido recientemente - Recently Played Tracks Pistas reproducidas recientemente - New Additions Nuevas adiciones - My recent activity Mi actividad reciente - Recent activity from %1 Actividad reciente de %1 @@ -1327,27 +1230,22 @@ Para más información, por favor visite http://gettomahawk.com/legal SourceTreeView - &Copy Link &Copiar enlace - &Delete %1 &Eliminar %1 - &Export Playlist &Exportar lista de reproducción - Save XSPF Guardar XSPF - Playlists (*.xspf) Listas de reproducción (*.xspf) @@ -1355,22 +1253,18 @@ Para más información, por favor visite http://gettomahawk.com/legal SourcesModel - Collection Colección - Playlist Lista de reproducción - Automatic Playlist Lista de reproducción automática - Station Estación @@ -1378,181 +1272,147 @@ Para más información, por favor visite http://gettomahawk.com/legal StackedSettingsDialog - Tomahawk Settings Preferencias de Tomahawk - Accounts Cuentas - Connect to your friends with Google Chat, Twitter, and more. - Conecta con tus amigos de Google Chat, Twitter y más. + Conecta con tus amigos con Google Chat, Twitter y más. - - ... ... - Local Music Information Información de música local - Path to scan for music files: Ruta para escanear archivos de música: - The Echo Nest supports keeping track of your catalog metadata and using it to craft personalized radios. Enabling this option will allow you (and all your friends) to create automatic playlists and stations based on your personal taste profile. - Echo Nest analiza los metadatos de tu colección + The Echo Nest analiza los metadatos de su colección y los emplea para crear radios personalizadas. Activando esta opción -te permitirá a ti (y a tus amigos) crear listas de reproducción automáticas -y estaciones basadas en tus gustos personales. +usted podrá (y sus amigos) crear listas de reproducción automáticas +y estaciones basadas en sus gustos personales. - Upload collection list to The Echo Nest to enable user radio Subir la lista de colección a Echo Nest para activar la radio del usuario - Watch for changes Vigilar los cambios en las carpetas - Time between scans, in seconds: Tiempo entre escaneo, en segundos: - Now Playing Information Información de pista en reproducción - Applications to update with currently playing track: Servicios a actualizar con la pista actualmente en reproducción: - Adium Adium - Scrobble tracks to Last.fm Enviar pistas a Last.fm - Username: Nombre de usuario: - Password: Contraseña: - Test Login Probar el inicio de sesión - Script Resolvers Scripts de resolvedores - Script resolvers search for a given track to make it playable. Los scripts de los resolvedores buscan y hacen reproducibles las pistas en línea. - Get more resolvers... Conseguir más resolvedores... - Advanced Network Settings Configuración avanzada de red - If you're having difficulty connecting to peers, try setting this to your external IP address/host name and a port number (default 50210). Make sure to forward that port to this machine! Si tiene dificultades para conectarse con los pares, intente establecer su dirección IP externa/nombre del host y el número de puerto (por defecto 50210). ¡Asegúrese de redireccionar ese puerto a esta máquina! - Static Host Name: Nombre estático del host: - Static Port: Puerto estático: - Always use static host name/port? (Overrides UPnP discovery/port forwarding) ¿Siempre usar nombre eśtático del host/puerto? (Sobreescribe descubrimiento UPnP/redirección de puertos) - Proxy Settings... Configuración del proxy... - Playdar HTTP API API HTTP de Playdar - Use UPnP to establish port forward Utilizar UPnP para establecer redirección de puertos + + Send reports after Tomahawk crashed + Mandar reportes después de que Tomahawk falle + Tomahawk::ContextMenu - - - &Play &Reproducir - - - Add to &Queue Añadir a la &cola - Copy Track &Link Copiar enlace de &pista - &Delete Items &Eliminar de la cola - &Delete Item &Eliminar de la cola @@ -1560,32 +1420,26 @@ y estaciones basadas en tus gustos personales. Tomahawk::CustomPlaylistView - Top Loved Tracks Pistas favoritas - Your loved tracks Tus pistas favoritas - %1's loved tracks Pistas favoritas de %1 - The most loved tracks from all your friends Las pistas favoritas de tus amigos - All of your loved tracks Todas tus pistas favoritas - All of %1's loved tracks Todas las pistas favoritas de %1 @@ -1593,12 +1447,10 @@ y estaciones basadas en tus gustos personales. Tomahawk::DropJobNotifier - Fetching %1 from database - Obteniendo %1 de base de datos + Obteniendo %1 de la base de datos - Parsing %1 %2 Analizando %1 %2 @@ -1606,7 +1458,6 @@ y estaciones basadas en tus gustos personales. Tomahawk::DynamicControlList - Click to collapse Click para contraer @@ -1614,8 +1465,6 @@ y estaciones basadas en tus gustos personales. Tomahawk::DynamicModel - - Could not find a playable track. Please change the filters or try again. @@ -1624,7 +1473,6 @@ Please change the filters or try again. Por favor, cambie los filtros o inténtelo de nuevo. - Failed to generate preview with the desired filters Fallo al generar vista previa con los filtros deseados @@ -1632,12 +1480,10 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::DynamicSetupWidget - Type: Tipo: - Generate Generar @@ -1645,17 +1491,14 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::DynamicView - Add some filters above to seed this station! ¡Añada algunos filtros para la estación! - Press Generate to get started! ¡Seleccione Generar para comenzar! - Add some filters above, and press Generate to get started! ¡Añada algunos filtros, y seleccione Generar para comenzar! @@ -1663,323 +1506,312 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::EchonestControl - - - - - - is es - from user del usuario - - No users with Echo Nest Catalogs enabled. Try enabling option in Collection settings - No hay usuario con los catálogos Echo Nest activados. Pruebe a activar la opción en la configuración de la colección + No hay usuarios con los catálogos Echo Nest activados. Pruebe a activar la opción en la configuración de la colección - similar to similar a - - - - - - - Less Menos - - - - - - - More Más - 0 BPM 0 BPM - 500 BPM 500 BPM - 0 secs 0 segundos - 3600 secs 3600 segundos - -100 dB -100 dB - 100 dB 100 db - Major Mayor - Minor Menor - C Do - C Sharp Do sostenido - D Re - E Flat Mi bemol - E Mi - F Fa - F Sharp Fa sostenido - G Sol - A Flat La bemol - A La - B Flat Si bemol - B Si - Ascending Ascendente - Descending Descendent - Tempo Tempo - Duration Duración - Loudness Volumen - Artist Familiarity Familiaridad del artista - Artist Hotttnesss Popularidad del artista - Song Hotttnesss Popularidad de la pista - Latitude Latitud - Longitude Duración - Mode Modo - Key Tonalidad - Energy Energía - Danceability Bailabilidad + + only by ~%1 + sólo por ~%1 + + + similar to ~%1 + similar a ~%1 + + + with genre ~%1 + con el género ~%1 + + + from no one + de ninguno + + + My Collection + Mi colección + + + from %1 radio + de %1 radio + + + with %1 %2 + con %1 %2 + + + about %1 BPM + sobre %1 BPM + + + about %n minute(s) long + + sobre %n minuto de duración + sobre %n minutos de duración + + + + about %1 dB + sobre %1 dB + + + at around %1%2 %3 + sobre %1%2 %3 + + + in %1 + en %1 + + + in a %1 key + en la tonalidad %1 + + + sorted in %1 %2 order + ordenado en %1 %2 + + + with a %1 mood + con un carácter %1 + + + in a %1 style + con un estilo %1 + Tomahawk::EchonestSteerer - Steer this station: Dirigir esta estación: - Takes effect on track change - Surge efecto al cambiar de pista + Surge efecto al cambiar de pista - Much less Mucho menos - Less Menos - A bit less Un poco menos - Keep at current Mantener en el actual - A bit more Un poco más - More Más - Much more Mucho más - Tempo Tempo - Loudness Volumen - Danceability Bailabilidad - Energy Energía - Song Hotttnesss Popularidad de la pista - Artist Hotttnesss Popularidad del artista - Artist Familiarity Familiaridad del artista - By Description Por descripción - Enter a description Introducir una descripción - Apply steering command Aplicar comando - Reset all steering commands Resetear todos los comandos @@ -1987,50 +1819,64 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::InfoSystem::ChartsPlugin - Top Overall Top total - Artists Artistas - Albums Álbumes - Tracks Pistas + + Tomahawk::InfoSystem::LastFmPlugin + + Top Tracks + Pistas más escuchadas + + + Loved Tracks + Pistas favoritas + + + Hyped Tracks + Pistas en alza + + + Top Artists + Artistas más escuchados + + + Hyped Artists + Artistas en alza + + Tomahawk::JSPFLoader - New Playlist Nueva lista de reproducción - Failed to save tracks Fallo al guardar pistas - Some tracks in the playlist do not contain an artist and a title. They will be ignored. - Algunas pistas en la lista de reproducción no contienen artista ni título. Serán ignoradas. + Algunas pistas en la lista de reproducción no contienen artista ni título. Éstas serán ignoradas. - XSPF Error Error XSPF - This is not a valid XSPF playlist. Esta no es una lista de reproducción XSPF válida. @@ -2038,13 +1884,10 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::LatchManager - &Catch Up &Actualizar - - &Listen Along &Escuchar juntos @@ -2052,72 +1895,65 @@ Por favor, cambie los filtros o inténtelo de nuevo. Tomahawk::Source - - Scanning (%L1 tracks) Escaneando (%L1 pistas) - Checking - Chequeando + Comprobando - Fetching Obteniendo - Parsing Analizando - Saving (%1%) Guardando (%1%) + + TomahawkApp + + My Collection + Mi colección + + TomahawkOAuthTwitter - Twitter PIN PIN de Twitter - After authenticating on Twitter's web site, enter the displayed PIN number here: Después de autenticarse en el sitio web de Twitter, -introduzca el número PIN aquí: +introduzca su número PIN aquí: TomahawkTrayIcon - - Hide Tomahawk Window Ocultar ventana de Tomahawk - Show Tomahawk Window Mostrar ventana de Tomahawk - Currently not playing. - No reproduciendo actualmente. + Ninguna pista en reproducción. - Play Reproducir - Pause Pausar @@ -2125,336 +1961,279 @@ introduzca el número PIN aquí: TomahawkWindow - Tomahawk Tomahawk - &Settings &Configuración - &Tomahawk &Tomahawk - &Network &Red - &Window &Ventana - &Help &Ayuda - &Quit &Salir - Ctrl+Q Ctrl+Q - Go &Online &Conectarse - Add &Friend... Añadir &amigo... - U&pdate Collection A&ctualizar colección - Update Collection Actualizar colección - &Configure Tomahawk... &Configurar Tomahawk... - Load &XSPF... Cargar &XSPF... - Create &New Playlist... Crear una &nueva lista de reproducción... - About &Tomahawk... Acerca de &Tomahawk... - Create New &Automatic Playlist Crear nueva &lista de reproducción automática - Create New &Station Crear nueva &estación - Show Offline Sources Mostrar fuentes fuera de línea - Hide Offline Sources Ocultar fuentes fuera de línea - Minimize Minimizar - Ctrl+M Ctrl+M - Zoom Zoom - Meta+Ctrl+Z Meta+Ctrl+Z - Diagnostics... Diagnósticos... - Fully &Rescan Collection &Re-escanear completamente la colección - Fully Rescan Collection Re-escanear completamente la colección - - Play Reproducir - Space Espacio - Previous Anterior - Next Siguiente - Global Search... Búsqueda global... - - Check For Updates... Buscar actualizaciones... - - - Connect To Peer Conectar a un par - Enter peer address: Introducir dirección del par: - Enter peer port: Introducir puerto del par: - Enter peer key: Introducir contraseña del par: - XSPF Error Error XSPF - This is not a valid XSPF playlist. Esta no es una lista de reproducción XSPF válida. - Failed to save tracks Fallo al guardar pistas - Some tracks in the playlist do not contain an artist and a title. They will be ignored. Algunas pistas en la lista de reproducción no contienen artista ni título. Serán ignoradas. - Create New Station Crear nueva estación - Name: Nombre: - New Station - Nueva emisora + Nueva estación - New Playlist Nueva lista de reproducción - Pause Pausar - Go &offline &Desconectarse - Go &online &Conectarse - Authentication Error Error de autenticación - %1 by %2 track, artist name %1 por %2 - %1 - %2 current track, some window title %1 - %2 - About Tomahawk Acerca de Tomahawk - <h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Hugo Lindstr&ouml;m, Michael Zanetti, Harald Sitter and Steve Robertson <h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>Gracias a: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Hugo Lindstr&ouml;m, Michael Zanetti, Harald Sitter y Steve Robertson + + Playback Error + Error de reproducción + + + Sorry, there is a problem accessing your audio device. Make sure you have a suitable Phonon backend and required plugins installed. + Hay un problema accediendo a su dispositivo de audio. Asegúrese que tiene un backend de Phonon adecuado y instalados los plugins requeridos. + + + Sorry, there is a problem accessing your audio device. + Hay un problema accediendo a su dispositivo de audio. + TopBar - Form Form - 0 Sources 0 fuentes - 0 Tracks 0 pistas - 0 Artists - 0 Artistas + 0 artistas - 0 Shown 0 mostradas - Tracks Pistas - Artists Artistas - Filter Filtro - Artist View Vista de artista - Flat View Vista simple - Sources Fuentes - Shown Mostradas @@ -2462,7 +2241,6 @@ introduzca el número PIN aquí: TopTracksContext - Top Hits Grandes éxitos @@ -2470,57 +2248,46 @@ introduzca el número PIN aquí: TrackModel - Artist Artista - Title Título - Album Álbum - Track Pista - Duration Duración - Bitrate Bitrate - Age Edad - Year Año - Size Tamaño - Origin Origen - Score Puntuación @@ -2528,7 +2295,6 @@ introduzca el número PIN aquí: TrackView - Sorry, your filter '%1' did not match any results. Lo siento, tu filtro '%1' no ha encontrado resultados. @@ -2536,12 +2302,10 @@ introduzca el número PIN aquí: TransferStatusItem - from de - to para @@ -2549,7 +2313,6 @@ introduzca el número PIN aquí: TreeItemDelegate - Unknown Desconocido @@ -2557,54 +2320,42 @@ introduzca el número PIN aquí: TreeModel - Name Nombre - Duration Duración - Bitrate Bitrate - Age Edad - Year Año - Size Tamaño - Origin Origen - All Artists Todos los artistas - - My Collection Mi colección - - Collection of %1 Colección de %1 @@ -2612,41 +2363,33 @@ introduzca el número PIN aquí: TwitterConfigWidget - Configure this Twitter account Configurar esta cuenta de Twitter - The Twitter plugin allows you to discover and play music from your Twitter friends running Tomahawk and post messages to your account. - El plugin de Twitter te permite descubrir y reproducir música de tus amigos de Twitter que usen Tomahawk y publicar mensajes en tu cuenta. + El plugin de Twitter le permite descubrir y reproducir música de sus amigos de Twitter que usen Tomahawk y además, publicar mensajes en tu cuenta. - - - Status: No saved credentials Estado: No hay credenciales guardadas - Authenticate with Twitter Autenticarse con Twitter - Twitter Connections Conexiones de Twitter - If you only want to post tweets, you're done. If you want to connect Tomahawk to your friends using Twitter, select the type of tweet and press the button below to send a sync message. You must both be following each other as Direct Messages are used. Then be (very) patient -- it can take several minutes! You can re-send a sync message at any time simply by sending another tweet using the button. - + Si sólo quiere postear tweets, ya está listo. Si quiere conectarse Tomahawk con sus amigos usando Twitter, seleccione el tipo de tweet y seleccione el botón siguiente para mandar un mensaje de sincronización. Deben seguirse mutuamente, ya que son usados mensajes directos. ¡Debe ser (muy) paciente -- puede llevar varios minutos! @@ -2654,148 +2397,121 @@ Si quiere conectarse Tomahawk con sus amigos usando Twitter, seleccione el tipo Puede reenviar el mensaje de sincronización en cualquier momento simplemente enviando otro tweet usando el botón. - Select the kind of tweet you would like, then press the button to post it: Seleccione el tipo de tweet, y pulse el botón para enviarlo: - - Global Tweet Tweet global - - @Mention @Mención - - Direct Message Mensaje directo - e.g. @tomahawk p. ej. @tomahawk - Send Message Enviar mensaje - - - Tweet! - ¡Twitear! + ¡Tweet! - - - Authenticate - Autenticar + Autenticarse - - Status: Credentials saved for %1 Estado: Credenciales guardadas para %1 - - De-authenticate - De-autenticarse + Desautenticarse - - - - - - - Tweetin' Error Error de tweet - The credentials could not be verified. You may wish to try re-authenticating. Las credenciales no pudieron ser verificadas. Si lo desea puede volver a autenticarse. - Status: Error validating credentials Estado: error al validar las credenciales - Send Message! ¡Enviar mensaje! - Send Mention! ¡Enviar mención! - You must enter a user name for this type of tweet. Debe introducir un nombre de usuario para este tipo de tweet. - Your saved credentials could not be loaded. You may wish to try re-authenticating. Sus credenciales guardadas no pudieron ser cargadas. Si lo desea puede volver a autenticarse. - Your saved credentials could not be verified. You may wish to try re-authenticating. Sus credenciales guardadas no pudieron ser verificadas. Si lo desea puede volver a autenticarse. - - There was an error posting your status -- sorry! Hubo un error al enviar su estado -- ¡lo siento! - - Tweeted! - ¡Twiteado! + ¡Tweeteado! - Your tweet has been posted! ¡Su tweet ha sido enviado! - There was an error posting your direct message -- sorry! Hubo un error al enviar su mensaje directo -- ¡lo siento! - Your message has been posted! ¡Su mensaje ha sido enviado! + + +If you only want to post tweets, you're done. + +If you want to connect Tomahawk to your friends using Twitter, select the type of tweet and press the button below to send a sync message. You must both be following each other as Direct Messages are used. Then be (very) patient -- it can take several minutes! + +You can re-send a sync message at any time simply by sending another tweet using the button. + +Si sólo desea enviar tweets, ya está listo. + +Si quiere conectar Tomahawk con sus amigos usando Twitter, seleccione el tipo de tweet y pulse el botón siguiente para mandar un mensaje de sincronización. Deben seguirse mutuamente, ya que se emplean los mensajes directos. ¡Debe ser (muy) paciente -- puede llevar varios minutos! + +Puede reenviar el mensaje de sincronización en cualquier momento simplemente enviando otro tweet mediante el botón. + TwitterPlugin - Twitter Twitter @@ -2803,40 +2519,33 @@ Si lo desea puede volver a autenticarse. ViewManager - All available tracks Todas las pistas disponibles - All available albums - Todas los álbumes disponibles + Todos los álbumes disponibles WelcomeWidget - Recent Additions Añadidos recientemente - Newest Stations & Playlists Nuevas estaciones y listas de reproducción - Recently Played Tracks Pistas reproducidas recientemente - No recently created playlists in your network. - No hay listas de reproducción recientemente creadas en tu red. + No hay listas de reproducción recientemente creadas en su red. - Welcome to Tomahawk Bienvenido a Tomahawk @@ -2844,7 +2553,6 @@ Si lo desea puede volver a autenticarse. WhatsHotWidget - Charts Listas de éxitos @@ -2852,7 +2560,6 @@ Si lo desea puede volver a autenticarse. WikipediaContext - Wikipedia Wikipedia @@ -2860,7 +2567,6 @@ Si lo desea puede volver a autenticarse. XMPPBot - Terms for %1: @@ -2868,12 +2574,10 @@ Terms for %1: Términos de %1: - No terms found, sorry. No se encuentran términos, lo siento. - Hotttness for %1: %2 @@ -2882,7 +2586,6 @@ Actualidad de %1: %2 - Familiarity for %1: %2 @@ -2891,7 +2594,6 @@ Familiaridad de %1: %2 - Lyrics for "%1" by %2: @@ -2907,7 +2609,6 @@ Letras de "%1" por %2: XSPFLoader - New Playlist Nueva lista de reproducción @@ -2915,78 +2616,62 @@ Letras de "%1" por %2: XmlConsole - Xml stream console Consola XML de stream - - Filter Filtro - Save log Guardar log - Disabled Desactivado - By JID Por JID - By namespace uri Por uri de namespace - By all attributes Por todos los atributos - Visible stanzas Estrofas visibles - Information query Consulta de información - Message Mensaje - Presence Presencia - Custom Personalizado - Close Cerrar - Save XMPP log to file Guardar XMPP log en un archivo - OpenDocument Format (*.odf);;HTML file (*.html);;Plain text (*.txt) Formato OpenDocument (*.odf);; archivo HTML (*.html);;texto plano (*.txt) @@ -2994,24 +2679,20 @@ Letras de "%1" por %2: ZeroconfConfig - Form Form - Local Network configuration Configuración de red local - This plugin will automatically find other users running Tomahawk on your local network Este plugin encontrará automáticamente a otros usuarios que estén ejecutando Tomahawk en su red local - Connect automatically when Tomahawk starts - Conectar automáticamente cuando se inicia Tomahawk + Conectar automáticamente cuando se inicie Tomahawk diff --git a/src/CMakeLists.linux.txt b/src/CMakeLists.linux.cmake similarity index 60% rename from src/CMakeLists.linux.txt rename to src/CMakeLists.linux.cmake index ae108e4d5..e3e207fa1 100644 --- a/src/CMakeLists.linux.txt +++ b/src/CMakeLists.linux.cmake @@ -2,9 +2,9 @@ FILE( GLOB _icons "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" ) FOREACH( _file ${_icons} ) STRING( REPLACE "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-" "" _res ${_file} ) STRING( REPLACE ".png" "" _res ${_res} ) - INSTALL( FILES ${_file} RENAME tomahawk.png DESTINATION share/icons/hicolor/${_res}/apps ) + INSTALL( FILES ${_file} RENAME tomahawk.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${_res}/apps ) ENDFOREACH( _file ) -INSTALL( FILES ${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon.svg RENAME tomahawk.svg DESTINATION share/icons/hicolor/scalable/apps ) +INSTALL( FILES ${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon.svg RENAME tomahawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps ) -INSTALL( FILES ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.desktop DESTINATION share/applications ) +INSTALL( FILES ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) diff --git a/src/CMakeLists.osx.txt b/src/CMakeLists.osx.cmake similarity index 100% rename from src/CMakeLists.osx.txt rename to src/CMakeLists.osx.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 088236165..48d6d4fec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,8 @@ SET( QT_USE_QTNETWORK TRUE ) SET( QT_USE_QTXML TRUE ) SET( QT_USE_QTWEBKIT TRUE ) +add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS ) + INCLUDE( ${QT_USE_FILE} ) INCLUDE( AddAppIconMacro ) @@ -176,10 +178,10 @@ INCLUDE_DIRECTORIES( SET( OS_SPECIFIC_LINK_LIBRARIES "" ) IF( WIN32 ) - INCLUDE( "CMakeLists.win32.txt" ) + INCLUDE( "CMakeLists.win32.cmake" ) ENDIF( WIN32 ) IF( UNIX ) - INCLUDE( "CMakeLists.unix.txt" ) + INCLUDE( "CMakeLists.unix.cmake" ) ENDIF( UNIX ) IF( APPLE ) @@ -205,6 +207,7 @@ IF(QCA2_FOUND) INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} ) ENDIF(QCA2_FOUND) +INCLUDE(GNUInstallDirs) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) @@ -270,12 +273,12 @@ IF( APPLE ) ENDIF(HAVE_SPARKLE) ENDIF( APPLE ) -INSTALL( TARGETS tomahawk BUNDLE DESTINATION . RUNTIME DESTINATION bin ) +INSTALL( TARGETS tomahawk BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) IF( UNIX AND NOT APPLE AND KDE4_INSTALLED AND LEGACY_KDE_INTEGRATION ) #install protocol file FILE( READ ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.protocol protocol ) STRING( REPLACE "/path/to/binary" # match this - "${CMAKE_INSTALL_PREFIX}/bin/tomahawk" # this is linux (kde) so pretty safe I think + "${CMAKE_INSTALL_FULL_BINDIR}/tomahawk" # this is linux (kde) so pretty safe I think edited_protocol # save in this variable "${protocol}" # from the contents of this var ) @@ -283,7 +286,7 @@ IF( UNIX AND NOT APPLE AND KDE4_INSTALLED AND LEGACY_KDE_INTEGRATION ) #install IF( ${SERVICES_INSTALL_DIR} ) SET( PROTOCOL_INSTALL_DIR ${SERVICES_INSTALL_DIR} ) ELSE() - SET( PROTOCOL_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/kde4/services" ) + SET( PROTOCOL_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/kde4/services" ) ENDIF() INSTALL( FILES ${CMAKE_BINARY_DIR}/tomahawk.protocol DESTINATION ${PROTOCOL_INSTALL_DIR} ) ENDIF() diff --git a/src/CMakeLists.unix.txt b/src/CMakeLists.unix.cmake similarity index 76% rename from src/CMakeLists.unix.txt rename to src/CMakeLists.unix.cmake index 975ddf20f..49caf297b 100644 --- a/src/CMakeLists.unix.txt +++ b/src/CMakeLists.unix.cmake @@ -7,9 +7,9 @@ ADD_DEFINITIONS( -fPIC ) SET( QXTWEB_LIBRARIES qxtweb-standalone ) IF( APPLE ) - INCLUDE( "CMakeLists.osx.txt" ) + INCLUDE( "CMakeLists.osx.cmake" ) ENDIF( APPLE ) IF( UNIX AND NOT APPLE ) - INCLUDE( "CMakeLists.linux.txt" ) + INCLUDE( "CMakeLists.linux.cmake" ) ENDIF( UNIX AND NOT APPLE ) diff --git a/src/CMakeLists.win32.txt b/src/CMakeLists.win32.cmake similarity index 100% rename from src/CMakeLists.win32.txt rename to src/CMakeLists.win32.cmake diff --git a/src/accounts/twitter/CMakeLists.txt b/src/accounts/twitter/CMakeLists.txt index 0b667d85f..253bd4e03 100644 --- a/src/accounts/twitter/CMakeLists.txt +++ b/src/accounts/twitter/CMakeLists.txt @@ -53,4 +53,4 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS tomahawk_account_twitter DESTINATION lib${LIB_SUFFIX} ) +install( TARGETS tomahawk_account_twitter DESTINATION ${CMAKE_INSTALL_LIBDIR} ) diff --git a/src/accounts/xmpp/CMakeLists.txt b/src/accounts/xmpp/CMakeLists.txt index 809ee5b03..e5e4e29ea 100644 --- a/src/accounts/xmpp/CMakeLists.txt +++ b/src/accounts/xmpp/CMakeLists.txt @@ -58,7 +58,7 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} ) +install( TARGETS tomahawk_account_xmpp DESTINATION ${CMAKE_INSTALL_LIBDIR} ) add_subdirectory(googlewrapper) diff --git a/src/accounts/xmpp/googlewrapper/CMakeLists.txt b/src/accounts/xmpp/googlewrapper/CMakeLists.txt index d8abd686f..62a7e6c25 100644 --- a/src/accounts/xmpp/googlewrapper/CMakeLists.txt +++ b/src/accounts/xmpp/googlewrapper/CMakeLists.txt @@ -34,4 +34,4 @@ target_link_libraries( tomahawk_account_google tomahawklib ) -install( TARGETS tomahawk_account_google DESTINATION lib${LIB_SUFFIX} ) +install( TARGETS tomahawk_account_google DESTINATION ${CMAKE_INSTALL_LIBDIR} ) diff --git a/src/accounts/zeroconf/CMakeLists.txt b/src/accounts/zeroconf/CMakeLists.txt index 657a41b53..66b22965f 100644 --- a/src/accounts/zeroconf/CMakeLists.txt +++ b/src/accounts/zeroconf/CMakeLists.txt @@ -44,4 +44,4 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS tomahawk_account_zeroconf DESTINATION lib${LIB_SUFFIX} ) +install( TARGETS tomahawk_account_zeroconf DESTINATION ${CMAKE_INSTALL_LIBDIR} ) \ No newline at end of file diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index 4649a889d..e14bd94c7 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -98,9 +98,12 @@ AudioControls::AudioControls( QWidget* parent ) ui->volumeSlider->setRange( 0, 100 ); ui->volumeSlider->setValue( AudioEngine::instance()->volume() ); + m_phononTickCheckTimer.setSingleShot( true ); + m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve ); ui->seekSlider->setTimeLine( &m_sliderTimeLine ); + connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) ); connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) ); connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) ); @@ -176,6 +179,13 @@ AudioControls::changeEvent( QEvent* e ) } +void +AudioControls::phononTickCheckTimeout() +{ + onPlaybackTimer( m_lastSliderCheck ); +} + + void AudioControls::onVolumeChanged( int volume ) { @@ -204,6 +214,8 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result ) ui->seekSlider->setRange( 0, duration ); ui->seekSlider->setValue( 0 ); + m_phononTickCheckTimer.stop(); + m_sliderTimeLine.stop(); m_sliderTimeLine.setDuration( duration ); m_sliderTimeLine.setFrameRange( 0, duration ); @@ -344,6 +356,7 @@ AudioControls::onPlaybackSeeked( qint64 msec ) tDebug( LOGEXTRA ) << Q_FUNC_INFO << " setting current timer to " << msec; m_sliderTimeLine.setPaused( true ); m_sliderTimeLine.setCurrentTime( msec ); + m_lastSliderCheck = msec; m_seekMsecs = msec; } @@ -373,16 +386,22 @@ AudioControls::onPlaybackStopped() void AudioControls::onPlaybackTimer( qint64 msElapsed ) { -// tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs; - if ( msElapsed > 0 && msElapsed - 500 < m_lastSliderCheck ) + //tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs; + if ( msElapsed > 0 && msElapsed != m_lastSliderCheck && m_seekMsecs == -1 && msElapsed - 500 < m_lastSliderCheck ) return; m_lastSliderCheck = msElapsed; if ( m_currentTrack.isNull() ) + { + m_sliderTimeLine.stop(); return; - + } + ui->seekSlider->blockSignals( true ); + if ( sender() != &m_phononTickCheckTimer ) + m_phononTickCheckTimer.start( 1000 ); + const int seconds = msElapsed / 1000; ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) ); ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) ); @@ -391,7 +410,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed ) { if ( m_sliderTimeLine.currentTime() != msElapsed ) { + m_sliderTimeLine.setPaused( true ); m_noTimeChange = false; + m_sliderTimeLine.setCurrentTime( msElapsed ); + m_seekMsecs = -1; m_sliderTimeLine.resume(); } } @@ -405,10 +427,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed ) m_sliderTimeLine.setCurrentTime( msElapsed ); m_seekMsecs = -1; - if ( AudioEngine::instance()->state() != AudioEngine::Paused ) + if ( AudioEngine::instance()->state() != AudioEngine::Paused && sender() != &m_phononTickCheckTimer ) m_sliderTimeLine.resume(); } - else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning ) + else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning && AudioEngine::instance()->state() == AudioEngine::Playing ) { ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() ); m_sliderTimeLine.start(); diff --git a/src/audiocontrols.h b/src/audiocontrols.h index 1929751f0..fa047634e 100644 --- a/src/audiocontrols.h +++ b/src/audiocontrols.h @@ -20,6 +20,7 @@ #define AUDIOCONTROLS_H #include +#include #include #include "result.h" @@ -51,7 +52,7 @@ signals: public slots: void onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); void onShuffleModeChanged( bool enabled ); - + protected: void changeEvent( QEvent* e ); void dragEnterEvent ( QDragEnterEvent* ); @@ -59,6 +60,8 @@ protected: void dropEvent ( QDropEvent* ); private slots: + void phononTickCheckTimeout(); + void onPlaybackStarted( const Tomahawk::result_ptr& result ); void onPlaybackLoading( const Tomahawk::result_ptr& result ); void onPlaybackPaused(); @@ -93,6 +96,7 @@ private: Tomahawk::PlaylistInterface::RepeatMode m_repeatMode; bool m_shuffled; + QTimer m_phononTickCheckTimer; QTimeLine m_sliderTimeLine; qint64 m_seekMsecs; qint64 m_lastSliderCheck; diff --git a/src/breakpad/BreakPad.cpp b/src/breakpad/BreakPad.cpp index a76b84124..0215d7796 100644 --- a/src/breakpad/BreakPad.cpp +++ b/src/breakpad/BreakPad.cpp @@ -82,14 +82,14 @@ BreakPad::BreakPad( const QString& path, bool active ) QString reporter; QString localReporter = QString( "%1/%2" ).arg( qApp->applicationDirPath() ).arg( CRASH_REPORTER_BINARY ); - QString globalReporter = QString( "%1/%2" ).arg( CMAKE_INSTALL_PREFIX "/" CMAKE_INSTALL_LIBEXECDIR ).arg( CRASH_REPORTER_BINARY ); + QString globalReporter = QString( "%1/%2" ).arg( CMAKE_INSTALL_FULL_LIBEXECDIR ).arg( CRASH_REPORTER_BINARY ); if ( QFileInfo( localReporter ).exists() ) reporter = localReporter; else if ( QFileInfo( globalReporter ).exists() ) reporter = globalReporter; else - tLog() << "Could not find \"" CRASH_REPORTER_BINARY "\" in \"" CMAKE_INSTALL_PREFIX "/" CMAKE_INSTALL_LIBEXECDIR "\" or application path"; + tLog() << "Could not find \"" CRASH_REPORTER_BINARY "\" in \"" CMAKE_INSTALL_FULL_LIBEXECDIR "\" or application path"; char* creporter; std::string sreporter = reporter.toStdString(); diff --git a/src/breakpad/CrashReporter/CMakeLists.txt b/src/breakpad/CrashReporter/CMakeLists.txt index 5040838ef..d1944bfcc 100644 --- a/src/breakpad/CrashReporter/CMakeLists.txt +++ b/src/breakpad/CrashReporter/CMakeLists.txt @@ -22,4 +22,4 @@ ADD_EXECUTABLE( tomahawk_crash_reporter WIN32 ${crashreporter_SOURCES} ${crashre TARGET_LINK_LIBRARIES( tomahawk_crash_reporter ${QT_LIBRARIES} tomahawklib ) INCLUDE(GNUInstallDirs) -install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) +install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR}) diff --git a/src/config.h.in b/src/config.h.in index ce0963ecd..42e6a346b 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -9,7 +9,7 @@ #cmakedefine DEBUG_BUILD #define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" -#define CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}" +#define CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}" #define CMAKE_SYSTEM "${CMAKE_SYSTEM}" #cmakedefine LION diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index cf5c7dff3..9c92ee5c6 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -11,6 +11,8 @@ include( ${QT_USE_FILE} ) add_definitions( ${QT_DEFINITIONS} ) add_definitions( -DQT_SHARED ) add_definitions( -DDLLEXPORT_PRO ) +add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS ) + set( libGuiSources actioncollection.cpp @@ -41,26 +43,32 @@ set( libGuiSources playlist/treemodel.cpp playlist/treeproxymodel.cpp + playlist/treeproxymodelplaylistinterface.cpp playlist/treeheader.cpp playlist/treeitemdelegate.cpp playlist/collectionproxymodel.cpp + playlist/collectionproxymodelplaylistinterface.cpp playlist/collectionflatmodel.cpp playlist/collectionview.cpp playlist/playlistmodel.cpp playlist/playlistproxymodel.cpp + playlist/playlistproxymodelplaylistinterface.cpp playlist/playlistview.cpp playlist/playlistitemdelegate.cpp playlist/queueproxymodel.cpp + playlist/queueproxymodelplaylistinterface.cpp playlist/queueview.cpp playlist/trackmodel.cpp playlist/trackmodelitem.cpp playlist/trackproxymodel.cpp + playlist/trackproxymodelplaylistinterface.cpp playlist/trackview.cpp playlist/trackheader.cpp playlist/treemodelitem.cpp playlist/albumitem.cpp playlist/albummodel.cpp playlist/albumproxymodel.cpp + playlist/albumproxymodelplaylistinterface.cpp playlist/albumitemdelegate.cpp playlist/albumview.cpp playlist/artistview.cpp @@ -166,26 +174,32 @@ set( libGuiHeaders playlist/treemodel.h playlist/treeproxymodel.h + playlist/treeproxymodelplaylistinterface.h playlist/treeheader.h playlist/treeitemdelegate.h playlist/collectionproxymodel.h + playlist/collectionproxymodelplaylistinterface.h playlist/collectionflatmodel.h playlist/collectionview.h playlist/playlistmodel.h playlist/playlistproxymodel.h + playlist/playlistproxymodelplaylistinterface.h playlist/playlistview.h playlist/playlistitemdelegate.h playlist/queueproxymodel.h + playlist/queueproxymodelplaylistinterface.h playlist/queueview.h playlist/trackmodel.h playlist/trackmodelitem.h playlist/trackproxymodel.h + playlist/trackproxymodelplaylistinterface.h playlist/trackview.h playlist/trackheader.h playlist/treemodelitem.h playlist/albumitem.h playlist/albummodel.h playlist/albumproxymodel.h + playlist/albumproxymodelplaylistinterface.h playlist/albumitemdelegate.h playlist/albumview.h playlist/artistview.h @@ -275,9 +289,12 @@ set( libSources aclsystem.cpp artist.cpp + artistplaylistinterface.cpp album.cpp + albumplaylistinterface.cpp collection.cpp playlist.cpp + playlistplaylistinterface.cpp resolver.cpp ExternalResolver.cpp query.cpp @@ -401,6 +418,8 @@ set( libHeaders pipeline.h functimeout.h + playlistinterface.h + aclsystem.h collection.h query.h @@ -411,8 +430,11 @@ set( libHeaders sourceplaylistinterface.h artist.h + artistplaylistinterface.h album.h + albumplaylistinterface.h playlist.h + playlistplaylistinterface.h accounts/Account.h accounts/AccountManager.h @@ -600,6 +622,7 @@ IF( WIN32 ) "dsound.dll" "winmm.dll" "advapi32.dll" + "shlwapi.dll" ) ENDIF( WIN32 ) @@ -677,7 +700,7 @@ TARGET_LINK_LIBRARIES( tomahawklib ) INSTALL( TARGETS tomahawklib - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) diff --git a/src/libtomahawk/LatchManager.cpp b/src/libtomahawk/LatchManager.cpp index f596f009e..5e5f3649c 100644 --- a/src/libtomahawk/LatchManager.cpp +++ b/src/libtomahawk/LatchManager.cpp @@ -34,7 +34,7 @@ LatchManager::LatchManager( QObject* parent ) : QObject( parent ) , m_state( NotLatched ) { - connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) ); + connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) ); } LatchManager::~LatchManager() @@ -58,11 +58,11 @@ LatchManager::latchRequest( const source_ptr& source ) m_state = Latching; m_waitingForLatch = source; - AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() ); + AudioEngine::instance()->playItem( source->getPlaylistInterface(), source->getPlaylistInterface()->nextItem() ); } void -LatchManager::playlistChanged( PlaylistInterface* ) +LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr ) { // If we were latched on and changed, send the listening along stop if ( m_latchedOnTo.isNull() ) @@ -108,7 +108,7 @@ LatchManager::playlistChanged( PlaylistInterface* ) m_latchedInterface.clear(); // call ourselves to hit the "create latch" condition - playlistChanged( 0 ); + playlistChanged( Tomahawk::playlistinterface_ptr() ); return; } m_latchedOnTo.clear(); @@ -133,7 +133,7 @@ LatchManager::unlatchRequest( const source_ptr& source ) { Q_UNUSED( source ); AudioEngine::instance()->stop(); - AudioEngine::instance()->setPlaylist( 0 ); + AudioEngine::instance()->setPlaylist( Tomahawk::playlistinterface_ptr() ); ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) ); } diff --git a/src/libtomahawk/LatchManager.h b/src/libtomahawk/LatchManager.h index a52af5aef..26d8b8f8f 100644 --- a/src/libtomahawk/LatchManager.h +++ b/src/libtomahawk/LatchManager.h @@ -45,8 +45,8 @@ public slots: void catchUpRequest(); private slots: - - void playlistChanged( Tomahawk::PlaylistInterface* ); + void playlistChanged( Tomahawk::playlistinterface_ptr ); + private: enum State { NotLatched = 0, diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp index ade2e33ef..7515b01bb 100644 --- a/src/libtomahawk/album.cpp +++ b/src/libtomahawk/album.cpp @@ -19,6 +19,7 @@ #include "album.h" #include "artist.h" +#include "albumplaylistinterface.h" #include "database/database.h" #include "database/databaseimpl.h" #include "database/databasecommand_alltracks.h" @@ -63,12 +64,10 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist ) - : PlaylistInterface( this ) + : QObject() , m_id( id ) , m_name( name ) , m_artist( artist ) - , m_currentItem( 0 ) - , m_currentTrack( 0 ) { } @@ -78,65 +77,28 @@ Album::onTracksAdded( const QList& tracks ) { qDebug() << Q_FUNC_INFO; - m_queries << tracks; + Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( getPlaylistInterface().data() ); + if ( api ) + api->addQueries( tracks ); + emit tracksAdded( tracks ); } -Tomahawk::result_ptr -Album::siblingItem( int itemsAway ) -{ - int p = m_currentTrack; - p += itemsAway; - - if ( p < 0 ) - return Tomahawk::result_ptr(); - - if ( p >= m_queries.count() ) - return Tomahawk::result_ptr(); - - m_currentTrack = p; - m_currentItem = m_queries.at( p )->results().first(); - return m_currentItem; -} - -result_ptr -Album::currentItem() const -{ - return m_currentItem; -} - -bool -Album::hasNextItem() -{ - int p = m_currentTrack; - p++; - if ( p < 0 || p >= m_queries.count() ) - return false; - - return true; -} - artist_ptr Album::artist() const { return m_artist; } -QList -Album::tracks() + +Tomahawk::playlistinterface_ptr +Album::getPlaylistInterface() { - if ( m_queries.isEmpty() ) + if ( m_playlistInterface.isNull() ) { - DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks(); - cmd->setAlbum( this ); - cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition ); - - connect( cmd, SIGNAL( tracks( QList, QVariant ) ), - SLOT( onTracksAdded( QList ) ) ); - - Database::instance()->enqueue( QSharedPointer( cmd ) ); + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) ); } - - return m_queries; -} + + return m_playlistInterface; +} \ No newline at end of file diff --git a/src/libtomahawk/album.h b/src/libtomahawk/album.h index 1681fb3ea..3ad460afd 100644 --- a/src/libtomahawk/album.h +++ b/src/libtomahawk/album.h @@ -19,8 +19,8 @@ #ifndef TOMAHAWKALBUM_H #define TOMAHAWKALBUM_H -#include -#include +#include +#include #include "typedefs.h" #include "playlistinterface.h" @@ -29,7 +29,7 @@ namespace Tomahawk { -class DLLEXPORT Album : public QObject, public PlaylistInterface +class DLLEXPORT Album : public QObject { Q_OBJECT @@ -37,56 +37,33 @@ public: static album_ptr get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate = false ); static album_ptr get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist ); - Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist ); - ~Album(); + explicit Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist ); + virtual ~Album(); unsigned int id() const { return m_id; } QString name() const { return m_name; } artist_ptr artist() const; - QList tracks(); - - virtual int trackCount() const { return m_queries.count(); } - virtual int unfilteredTrackCount() const { return m_queries.count(); } - - virtual Tomahawk::result_ptr siblingItem( int itemsAway ); - - virtual bool hasNextItem(); - virtual Tomahawk::result_ptr currentItem() const; - - virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } - virtual bool shuffled() const { return false; } - - virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} - virtual void setShuffled( bool ) {} - - virtual void setFilter( const QString& /*pattern*/ ) {} + Tomahawk::playlistinterface_ptr getPlaylistInterface(); signals: - void repeatModeChanged( PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - void tracksAdded( const QList& tracks ); - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - - void nextTrackReady(); private slots: void onTracksAdded( const QList& tracks ); private: - Album(); + Q_DISABLE_COPY( Album ) + explicit Album(); unsigned int m_id; QString m_name; artist_ptr m_artist; - QList m_queries; - result_ptr m_currentItem; - unsigned int m_currentTrack; + + Tomahawk::playlistinterface_ptr m_playlistInterface; }; -}; // ns +} // ns #endif diff --git a/src/libtomahawk/albumplaylistinterface.cpp b/src/libtomahawk/albumplaylistinterface.cpp new file mode 100644 index 000000000..791aecafd --- /dev/null +++ b/src/libtomahawk/albumplaylistinterface.cpp @@ -0,0 +1,108 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "albumplaylistinterface.h" + +#include "artist.h" +#include "database/database.h" +#include "database/databaseimpl.h" +#include "database/databasecommand_alltracks.h" +#include "query.h" + +#include "utils/logger.h" + +using namespace Tomahawk; + +AlbumPlaylistInterface::AlbumPlaylistInterface() {} + +AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album ) + : Tomahawk::PlaylistInterface() + , m_currentItem( 0 ) + , m_currentTrack( 0 ) + , m_album( QWeakPointer< Tomahawk::Album >( album ) ) +{ +} + + +AlbumPlaylistInterface::~AlbumPlaylistInterface() +{ + m_album.clear(); +} + + +Tomahawk::result_ptr +AlbumPlaylistInterface::siblingItem( int itemsAway ) +{ + int p = m_currentTrack; + p += itemsAway; + + if ( p < 0 ) + return Tomahawk::result_ptr(); + + if ( p >= m_queries.count() ) + return Tomahawk::result_ptr(); + + m_currentTrack = p; + m_currentItem = m_queries.at( p )->results().first(); + return m_currentItem; +} + + +result_ptr +AlbumPlaylistInterface::currentItem() const +{ + return m_currentItem; +} + + +bool +AlbumPlaylistInterface::hasNextItem() +{ + int p = m_currentTrack; + p++; + if ( p < 0 || p >= m_queries.count() ) + return false; + + return true; +} + + +QList< Tomahawk::query_ptr > +AlbumPlaylistInterface::tracks() +{ + if ( m_queries.isEmpty() && m_album ) + { + DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks(); + cmd->setAlbum( m_album.data() ); + cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition ); + + connect( cmd, SIGNAL( tracks( QList, QVariant ) ), + SLOT( onTracksAdded( QList ) ) ); + + Database::instance()->enqueue( QSharedPointer( cmd ) ); + } + + return m_queries; +} + + +void +AlbumPlaylistInterface::addQueries( const QList< query_ptr >& tracks ) +{ + m_queries << tracks; +} diff --git a/src/libtomahawk/albumplaylistinterface.h b/src/libtomahawk/albumplaylistinterface.h new file mode 100644 index 000000000..486a0871a --- /dev/null +++ b/src/libtomahawk/albumplaylistinterface.h @@ -0,0 +1,83 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TOMAHAWKALBUMPLAYLISTINTERFACE_H +#define TOMAHAWKALBUMPLAYLISTINTERFACE_H + +#include +#include + +#include "album.h" +#include "typedefs.h" +#include "playlistinterface.h" +#include "dllmacro.h" + +namespace Tomahawk +{ + +class DLLEXPORT AlbumPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + AlbumPlaylistInterface( Tomahawk::Album *album ); + virtual ~AlbumPlaylistInterface(); + + QList tracks(); + + virtual int trackCount() const { return m_queries.count(); } + virtual int unfilteredTrackCount() const { return m_queries.count(); } + + virtual Tomahawk::result_ptr siblingItem( int itemsAway ); + + virtual bool hasNextItem(); + virtual Tomahawk::result_ptr currentItem() const; + + virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } + virtual bool shuffled() const { return false; } + + virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} + virtual void setShuffled( bool ) {} + + virtual void setFilter( const QString& /*pattern*/ ) {} + + virtual void addQueries( const QList& tracks ); + +signals: + void repeatModeChanged( PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + + void nextTrackReady(); + +private: + Q_DISABLE_COPY( AlbumPlaylistInterface ) + AlbumPlaylistInterface(); + + QList< Tomahawk::query_ptr > m_queries; + result_ptr m_currentItem; + unsigned int m_currentTrack; + + QWeakPointer< Tomahawk::Album > m_album; +}; + +}; // ns + +#endif diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp index 263c57804..eafd6b7e7 100644 --- a/src/libtomahawk/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -18,10 +18,10 @@ #include "artist.h" +#include "artistplaylistinterface.h" #include "collection.h" #include "database/database.h" #include "database/databaseimpl.h" -#include "database/databasecommand_alltracks.h" #include "query.h" #include "utils/logger.h" @@ -71,11 +71,9 @@ Artist::get( unsigned int id, const QString& name ) Artist::Artist( unsigned int id, const QString& name ) - : PlaylistInterface( this ) + : QObject() , m_id( id ) , m_name( name ) - , m_currentItem( 0 ) - , m_currentTrack( 0 ) { m_sortname = DatabaseImpl::sortname( name, true ); } @@ -86,61 +84,19 @@ Artist::onTracksAdded( const QList& tracks ) { qDebug() << Q_FUNC_INFO; - m_queries << tracks; + Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( getPlaylistInterface().data() ); + if ( api ) + api->addQueries( tracks ); emit tracksAdded( tracks ); } - -Tomahawk::result_ptr -Artist::siblingItem( int itemsAway ) +Tomahawk::playlistinterface_ptr +Artist::getPlaylistInterface() { - int p = m_currentTrack; - p += itemsAway; - - if ( p < 0 ) - return Tomahawk::result_ptr(); - - if ( p >= m_queries.count() ) - return Tomahawk::result_ptr(); - - m_currentTrack = p; - m_currentItem = m_queries.at( p )->results().first(); - return m_currentItem; -} - - -bool -Artist::hasNextItem() -{ - int p = m_currentTrack; - p++; - if ( p < 0 || p >= m_queries.count() ) - return false; - - return true; -} - -result_ptr -Artist::currentItem() const -{ - return m_currentItem; -} - - -QList -Artist::tracks() -{ - if ( m_queries.isEmpty() ) + if ( m_playlistInterface.isNull() ) { - DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks(); - cmd->setArtist( this ); - cmd->setSortOrder( DatabaseCommand_AllTracks::Album ); - - connect( cmd, SIGNAL( tracks( QList, QVariant ) ), - SLOT( onTracksAdded( QList ) ) ); - - Database::instance()->enqueue( QSharedPointer( cmd ) ); + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::ArtistPlaylistInterface( this ) ); } - return m_queries; + return m_playlistInterface; } diff --git a/src/libtomahawk/artist.h b/src/libtomahawk/artist.h index b85fabbbd..be7db3704 100644 --- a/src/libtomahawk/artist.h +++ b/src/libtomahawk/artist.h @@ -19,75 +19,49 @@ #ifndef TOMAHAWKARTIST_H #define TOMAHAWKARTIST_H -#include -#include +#include +#include #include "typedefs.h" -#include "playlistinterface.h" #include "dllmacro.h" namespace Tomahawk { -class DLLEXPORT Artist : public QObject, public PlaylistInterface +class DLLEXPORT Artist : public QObject { Q_OBJECT public: static artist_ptr get( const QString& name, bool autoCreate = false ); static artist_ptr get( unsigned int id, const QString& name ); - Artist( unsigned int id, const QString& name ); + explicit Artist( unsigned int id, const QString& name ); - Artist(); + explicit Artist(); virtual ~Artist(); unsigned int id() const { return m_id; } QString name() const { return m_name; } QString sortname() const { return m_sortname; } - virtual QList tracks(); - - virtual int trackCount() const { return 0; } - virtual int unfilteredTrackCount() const { return m_queries.count(); } - - virtual Tomahawk::result_ptr siblingItem( int itemsAway ); - - virtual bool hasNextItem(); - virtual Tomahawk::result_ptr currentItem() const; - - virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } - virtual bool shuffled() const { return false; } - - virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} - virtual void setShuffled( bool ) {} - - virtual void setFilter( const QString& /*pattern*/ ) {} + Tomahawk::playlistinterface_ptr getPlaylistInterface(); signals: - void repeatModeChanged( PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - void tracksAdded( const QList& tracks ); - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - - void nextTrackReady(); private slots: void onTracksAdded( const QList& tracks ); private: - Q_DISABLE_COPY(Artist) + Q_DISABLE_COPY( Artist ) unsigned int m_id; QString m_name; QString m_sortname; - QList m_queries; - result_ptr m_currentItem; - unsigned int m_currentTrack; + Tomahawk::playlistinterface_ptr m_playlistInterface; }; -}; // ns +} // ns #endif diff --git a/src/libtomahawk/artistplaylistinterface.cpp b/src/libtomahawk/artistplaylistinterface.cpp new file mode 100644 index 000000000..6f22397ad --- /dev/null +++ b/src/libtomahawk/artistplaylistinterface.cpp @@ -0,0 +1,106 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "artistplaylistinterface.h" + +#include "artist.h" +#include "collection.h" +#include "query.h" +#include "database/database.h" +#include "database/databasecommand_alltracks.h" + +#include "utils/logger.h" + +using namespace Tomahawk; + + +ArtistPlaylistInterface::ArtistPlaylistInterface( Tomahawk::Artist *artist ) + : Tomahawk::PlaylistInterface() + , m_currentItem( 0 ) + , m_currentTrack( 0 ) + , m_artist( QWeakPointer< Tomahawk::Artist >( artist ) ) +{ +} + + +ArtistPlaylistInterface::~ArtistPlaylistInterface() +{ + m_artist.clear(); +} + + +Tomahawk::result_ptr +ArtistPlaylistInterface::siblingItem( int itemsAway ) +{ + int p = m_currentTrack; + p += itemsAway; + + if ( p < 0 ) + return Tomahawk::result_ptr(); + + if ( p >= m_queries.count() ) + return Tomahawk::result_ptr(); + + m_currentTrack = p; + m_currentItem = m_queries.at( p )->results().first(); + return m_currentItem; +} + + +bool +ArtistPlaylistInterface::hasNextItem() +{ + int p = m_currentTrack; + p++; + if ( p < 0 || p >= m_queries.count() ) + return false; + + return true; +} + +result_ptr +ArtistPlaylistInterface::currentItem() const +{ + return m_currentItem; +} + + +QList +ArtistPlaylistInterface::tracks() +{ + if ( m_queries.isEmpty() && m_artist ) + { + DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks(); + cmd->setArtist( m_artist.data() ); + cmd->setSortOrder( DatabaseCommand_AllTracks::Album ); + + connect( cmd, SIGNAL( tracks( QList, QVariant ) ), + SLOT( onTracksAdded( QList ) ) ); + + Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); + } + + return m_queries; +} + + +void +ArtistPlaylistInterface::addQueries( const QList< query_ptr >& tracks ) +{ + m_queries << tracks; +} diff --git a/src/libtomahawk/artistplaylistinterface.h b/src/libtomahawk/artistplaylistinterface.h new file mode 100644 index 000000000..65f81f7ff --- /dev/null +++ b/src/libtomahawk/artistplaylistinterface.h @@ -0,0 +1,82 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TOMAHAWKARTISTPLAYLISTINTERFACE_H +#define TOMAHAWKARTISTPLAYLISTINTERFACE_H + +#include +#include + +#include "artist.h" +#include "typedefs.h" +#include "playlistinterface.h" +#include "dllmacro.h" + +namespace Tomahawk +{ + +class DLLEXPORT ArtistPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + ArtistPlaylistInterface( Tomahawk::Artist *artist ); + virtual ~ArtistPlaylistInterface(); + + virtual QList tracks(); + + virtual int trackCount() const { return 0; } + virtual int unfilteredTrackCount() const { return m_queries.count(); } + + virtual Tomahawk::result_ptr siblingItem( int itemsAway ); + + virtual bool hasNextItem(); + virtual Tomahawk::result_ptr currentItem() const; + + virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } + virtual bool shuffled() const { return false; } + + virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} + virtual void setShuffled( bool ) {} + + virtual void setFilter( const QString& /*pattern*/ ) {} + + virtual void addQueries( const QList& tracks ); + +signals: + void repeatModeChanged( PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + + void nextTrackReady(); + +private: + Q_DISABLE_COPY( ArtistPlaylistInterface ) + + QList< Tomahawk::query_ptr > m_queries; + result_ptr m_currentItem; + unsigned int m_currentTrack; + + QWeakPointer< Tomahawk::Artist > m_artist; +}; + +}; // ns + +#endif diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index 2a4a8bfc7..9be1cf518 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -554,7 +554,7 @@ AudioEngine::loadNextTrack() void -AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result ) +AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result ) { tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() ); @@ -562,7 +562,7 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re m_playlist.data()->reset(); setPlaylist( playlist ); - m_currentTrackPlaylist = playlist->getSharedPointer(); + m_currentTrackPlaylist = playlist; if ( !result.isNull() ) loadTrack( result ); @@ -678,26 +678,26 @@ AudioEngine::timerTriggered( qint64 time ) void -AudioEngine::setPlaylist( PlaylistInterface* playlist ) +AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist ) { if ( !m_playlist.isNull() ) { - if ( m_playlist.data()->object() && m_playlist.data()->retryMode() == PlaylistInterface::Retry ) - disconnect( m_playlist.data()->object(), SIGNAL( nextTrackReady() ) ); + if ( m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry ) + disconnect( m_playlist.data(), SIGNAL( nextTrackReady() ) ); m_playlist.data()->reset(); } - if ( !playlist ) + if ( playlist.isNull() ) { m_playlist.clear(); emit playlistChanged( playlist ); return; } - m_playlist = playlist->getSharedPointer(); + m_playlist = playlist; - if ( m_playlist.data()->object() && m_playlist.data()->retryMode() == PlaylistInterface::Retry ) - connect( m_playlist.data()->object(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) ); + if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry ) + connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) ); emit playlistChanged( playlist ); } diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h index d90db5f27..4b19a8c02 100644 --- a/src/libtomahawk/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -19,8 +19,8 @@ #ifndef AUDIOENGINE_H #define AUDIOENGINE_H -#include -#include +#include +#include #include #include @@ -30,15 +30,12 @@ #include "result.h" #include "typedefs.h" +#include "playlistinterface.h" #include "dllmacro.h" #define AUDIO_VOLUME_STEP 5 -namespace Tomahawk -{ - class PlaylistInterface; -} class DLLEXPORT AudioEngine : public QObject { @@ -62,10 +59,10 @@ public: bool isStopped() const { return m_state == Stopped; } /* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */ - Tomahawk::PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist.data(); } + Tomahawk::playlistinterface_ptr currentTrackPlaylist() const { return m_currentTrackPlaylist; } /* Returns the PlaylistInterface of the current playlist. Note: The currently playing track might still be from a different playlist! */ - Tomahawk::PlaylistInterface* playlist() const { return m_playlist.data(); } + Tomahawk::playlistinterface_ptr playlist() const { return m_playlist; } Tomahawk::result_ptr currentTrack() const { return m_currentTrack; } @@ -93,9 +90,9 @@ public slots: void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); } void mute(); - void playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result ); - void setPlaylist( Tomahawk::PlaylistInterface* playlist ); - void setQueue( Tomahawk::PlaylistInterface* queue ) { m_queue = queue; } + void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result ); + void setPlaylist( Tomahawk::playlistinterface_ptr playlist ); + void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; } void playlistNextTrackReady(); @@ -119,7 +116,7 @@ signals: void timerSeconds( unsigned int secondsElapsed ); void timerPercentage( unsigned int percentage ); - void playlistChanged( Tomahawk::PlaylistInterface* playlist ); + void playlistChanged( Tomahawk::playlistinterface_ptr playlist ); void error( AudioEngine::AudioErrorCode errorCode ); @@ -147,9 +144,9 @@ private: Tomahawk::result_ptr m_currentTrack; Tomahawk::result_ptr m_lastTrack; - QWeakPointer< Tomahawk::PlaylistInterface > m_playlist; - QWeakPointer< Tomahawk::PlaylistInterface > m_currentTrackPlaylist; - Tomahawk::PlaylistInterface* m_queue; + Tomahawk::playlistinterface_ptr m_playlist; + Tomahawk::playlistinterface_ptr m_currentTrackPlaylist; + Tomahawk::playlistinterface_ptr m_queue; Phonon::MediaObject* m_mediaObject; Phonon::AudioOutput* m_audioOutput; diff --git a/src/libtomahawk/collection.cpp b/src/libtomahawk/collection.cpp index fc86de857..795e74cd3 100644 --- a/src/libtomahawk/collection.cpp +++ b/src/libtomahawk/collection.cpp @@ -149,24 +149,24 @@ Collection::deleteStation( const dynplaylist_ptr& s ) } -playlist_ptr +Tomahawk::playlist_ptr Collection::playlist( const QString& guid ) { - return m_playlists.value( guid, playlist_ptr() ); + return m_playlists.value( guid, Tomahawk::playlist_ptr() ); } -dynplaylist_ptr +Tomahawk::dynplaylist_ptr Collection::autoPlaylist( const QString& guid ) { - return m_autoplaylists.value( guid, dynplaylist_ptr() ); + return m_autoplaylists.value( guid, Tomahawk::dynplaylist_ptr() ); } -dynplaylist_ptr +Tomahawk::dynplaylist_ptr Collection::station( const QString& guid ) { - return m_stations.value( guid, dynplaylist_ptr() ); + return m_stations.value( guid, Tomahawk::dynplaylist_ptr() ); } diff --git a/src/libtomahawk/context/ContextPage.h b/src/libtomahawk/context/ContextPage.h index 6e19bf409..1c35b91a6 100644 --- a/src/libtomahawk/context/ContextPage.h +++ b/src/libtomahawk/context/ContextPage.h @@ -43,7 +43,7 @@ public: virtual ~ContextPage() {} virtual QGraphicsWidget* widget() = 0; - virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0; virtual QString title() const = 0; virtual QString description() const = 0; diff --git a/src/libtomahawk/context/pages/RelatedArtistsContext.h b/src/libtomahawk/context/pages/RelatedArtistsContext.h index 47f4ef138..971e3e595 100644 --- a/src/libtomahawk/context/pages/RelatedArtistsContext.h +++ b/src/libtomahawk/context/pages/RelatedArtistsContext.h @@ -42,7 +42,7 @@ public: virtual QGraphicsWidget* widget() { return m_proxy; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return tr( "Related Artists" ); } virtual QString description() const { return QString(); } diff --git a/src/libtomahawk/context/pages/TopTracksContext.h b/src/libtomahawk/context/pages/TopTracksContext.h index d74abda7c..68f1b8a91 100644 --- a/src/libtomahawk/context/pages/TopTracksContext.h +++ b/src/libtomahawk/context/pages/TopTracksContext.h @@ -42,7 +42,7 @@ public: virtual QGraphicsWidget* widget() { return m_proxy; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return tr( "Top Hits" ); } virtual QString description() const { return QString(); } diff --git a/src/libtomahawk/context/pages/WikipediaContext.h b/src/libtomahawk/context/pages/WikipediaContext.h index 54fe011e6..318e6bfb3 100644 --- a/src/libtomahawk/context/pages/WikipediaContext.h +++ b/src/libtomahawk/context/pages/WikipediaContext.h @@ -36,7 +36,7 @@ public: WikipediaContext() : WebContext() {} ~WikipediaContext() {} - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return tr( "Wikipedia" ); } virtual QString description() const { return QString(); } @@ -61,7 +61,7 @@ public: LastfmContext() : WebContext() {} ~LastfmContext() {} - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return tr( "Last.fm" ); } virtual QString description() const { return QString(); } diff --git a/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp b/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp index 2810c7610..eb99d0f55 100644 --- a/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libtomahawk/database/databasecommand_createdynamicplaylist.h b/src/libtomahawk/database/databasecommand_createdynamicplaylist.h index c935e26e5..d68edaa53 100644 --- a/src/libtomahawk/database/databasecommand_createdynamicplaylist.h +++ b/src/libtomahawk/database/databasecommand_createdynamicplaylist.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libtomahawk/dropjob.cpp b/src/libtomahawk/dropjob.cpp index 5e67b724e..3afabb540 100644 --- a/src/libtomahawk/dropjob.cpp +++ b/src/libtomahawk/dropjob.cpp @@ -764,7 +764,7 @@ QList< query_ptr > DropJob::getArtist( const QString &artist ) { artist_ptr artistPtr = Artist::get( artist ); - if ( artistPtr->tracks().isEmpty() ) + if ( artistPtr->getPlaylistInterface()->tracks().isEmpty() ) { connect( artistPtr.data(), SIGNAL( tracksAdded( QList ) ), SLOT( onTracksAdded( QList ) ) ); @@ -772,7 +772,7 @@ DropJob::getArtist( const QString &artist ) return QList< query_ptr >(); } else - return artistPtr->tracks(); + return artistPtr->getPlaylistInterface()->tracks(); } @@ -785,7 +785,7 @@ DropJob::getAlbum(const QString &artist, const QString &album) if ( albumPtr.isNull() ) return QList< query_ptr >(); - if ( albumPtr->tracks().isEmpty() ) + if ( albumPtr->getPlaylistInterface()->tracks().isEmpty() ) { m_dropJob = new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album ); connect( albumPtr.data(), SIGNAL( tracksAdded( QList ) ), @@ -796,7 +796,7 @@ DropJob::getAlbum(const QString &artist, const QString &album) return QList< query_ptr >(); } else - return albumPtr->tracks(); + return albumPtr->getPlaylistInterface()->tracks(); } diff --git a/src/libtomahawk/globalactionmanager.cpp b/src/libtomahawk/globalactionmanager.cpp index 9ba2479d6..6d5fcbbaa 100644 --- a/src/libtomahawk/globalactionmanager.cpp +++ b/src/libtomahawk/globalactionmanager.cpp @@ -596,19 +596,19 @@ GlobalActionManager::handleAutoPlaylistCommand( const QUrl& url ) } -dynplaylist_ptr +Tomahawk::dynplaylist_ptr GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station ) { QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command if( parts.isEmpty() ) { tLog() << "No specific station command:" << url.toString(); - return dynplaylist_ptr(); + return Tomahawk::dynplaylist_ptr(); } if( parts[ 0 ] == "create" ) { if( !url.hasQueryItem( "title" ) || !url.hasQueryItem( "type" ) ) { tLog() << "Station create command needs title and type..." << url.toString(); - return dynplaylist_ptr(); + return Tomahawk::dynplaylist_ptr(); } QString title = url.queryItemValue( "title" ); QString type = url.queryItemValue( "type" ); @@ -737,7 +737,7 @@ GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station ) return pl; } - return dynplaylist_ptr(); + return Tomahawk::dynplaylist_ptr(); } @@ -1012,7 +1012,7 @@ GlobalActionManager::waitingForResolved( bool /* success */ ) // AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() ); if ( sender() && sender()->property( "playNow" ).toBool() ) { - if ( AudioEngine::instance()->playlist() ) + if ( !AudioEngine::instance()->playlist().isNull() ) AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() ); else { diff --git a/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.cpp b/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.cpp index 9067e5669..58a514d49 100644 --- a/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.cpp @@ -62,13 +62,13 @@ MprisPlugin::MprisPlugin() SLOT( onVolumeChanged( int ) ) ); // When the playlist changes, signals for several properties are sent - connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), - SLOT( onPlaylistChanged( Tomahawk::PlaylistInterface* ) ) ); + connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), + SLOT( onPlaylistChanged( Tomahawk::playlistinterface_ptr ) ) ); // When a track is added or removed, CanGoNext updated signal is sent - PlaylistInterface *playlist = AudioEngine::instance()->playlist(); - if( playlist ) - connect( playlist->object(), SIGNAL( trackCountChanged( unsigned int ) ), + Tomahawk::playlistinterface_ptr playlist = AudioEngine::instance()->playlist(); + if( !playlist.isNull() ) + connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); // Connect to AudioEngine's seeked signal @@ -182,15 +182,15 @@ bool MprisPlugin::canPlay() const { // If there is a currently playing track, or if there is a playlist with at least 1 track, you can hit play - PlaylistInterface *p = AudioEngine::instance()->playlist(); - return AudioEngine::instance()->currentTrack() || ( p && p->trackCount() ); + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + return AudioEngine::instance()->currentTrack() || ( !p.isNull() && p->trackCount() ); } bool MprisPlugin::canSeek() const { - PlaylistInterface *p = AudioEngine::instance()->playlist(); - if (!p) + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + if ( p.isNull() ) return false; return p->seekRestrictions() != PlaylistInterface::NoSeek; @@ -199,8 +199,8 @@ MprisPlugin::canSeek() const QString MprisPlugin::loopStatus() const { - PlaylistInterface *p = AudioEngine::instance()->playlist(); - if (!p) + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + if ( p.isNull() ) return "None"; PlaylistInterface::RepeatMode mode = p->repeatMode(); switch( mode ) @@ -225,8 +225,8 @@ MprisPlugin::loopStatus() const void MprisPlugin::setLoopStatus( const QString &value ) { - PlaylistInterface *p = AudioEngine::instance()->playlist(); - if (!p) + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + if ( p.isNull() ) return; if( value == "Track") p->setRepeatMode( PlaylistInterface::RepeatOne ); @@ -314,8 +314,8 @@ MprisPlugin::setRate( double value ) bool MprisPlugin::shuffle() const { - PlaylistInterface *p = AudioEngine::instance()->playlist(); - if (!p) + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + if ( p.isNull() ) return false; return p->shuffled(); } @@ -323,8 +323,8 @@ MprisPlugin::shuffle() const void MprisPlugin::setShuffle( bool value ) { - PlaylistInterface *p = AudioEngine::instance()->playlist(); - if (!p) + Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); + if ( p.isNull() ) return; return p->setShuffled( value ); } @@ -539,16 +539,16 @@ MprisPlugin::onVolumeChanged( int volume ) } void -MprisPlugin::onPlaylistChanged( Tomahawk::PlaylistInterface* playlist ) +MprisPlugin::onPlaylistChanged( Tomahawk::playlistinterface_ptr playlist ) { qDebug() << Q_FUNC_INFO; disconnect( this, SLOT( onTrackCountChanged( unsigned int ) ) ); qDebug() << "disconnected"; - if( playlist ) + if( !playlist.isNull() ) qDebug() << "playlist not null"; - if( playlist ) - connect( playlist->object(), SIGNAL( trackCountChanged( unsigned int ) ), + if( !playlist.isNull() ) + connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); qDebug() << "connected new playlist"; diff --git a/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h b/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h index 2ba684808..db87ca37c 100644 --- a/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h @@ -146,7 +146,7 @@ protected slots: private slots: void stateChanged( AudioState newState, AudioState oldState ); void onVolumeChanged( int volume ); - void onPlaylistChanged( Tomahawk::PlaylistInterface* playlist); + void onPlaylistChanged( Tomahawk::playlistinterface_ptr ); void onTrackCountChanged( unsigned int tracks ); void onSeeked( qint64 ms ); diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp index bd07027a8..fcf0f3cc3 100644 --- a/src/libtomahawk/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -18,8 +18,8 @@ #include "playlist.h" -#include -#include +#include +#include #include "database/database.h" #include "database/databasecommand_loadplaylistentries.h" @@ -32,6 +32,7 @@ #include "pipeline.h" #include "source.h" #include "sourcelist.h" +#include "playlistplaylistinterface.h" #include "utils/logger.h" #include "PlaylistUpdaterInterface.h" @@ -562,17 +563,6 @@ Playlist::newEntries( const QList< plentry_ptr >& entries ) } -QList -Playlist::tracks() -{ - QList queries; - foreach( const plentry_ptr& p, m_entries ) - queries << p->query(); - - return queries; -} - - void Playlist::setBusy( bool b ) { @@ -602,3 +592,15 @@ Playlist::checkRevisionQueue() createNewRevision( item.newRev, item.oldRev, item.entries ); } } + + +Tomahawk::playlistinterface_ptr +Playlist::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlaylistPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist.h b/src/libtomahawk/playlist.h index 6175bb653..5a6e04568 100644 --- a/src/libtomahawk/playlist.h +++ b/src/libtomahawk/playlist.h @@ -114,7 +114,7 @@ public: }; -class DLLEXPORT Playlist : public QObject, public PlaylistInterface +class DLLEXPORT Playlist : public QObject { Q_OBJECT Q_PROPERTY( QString guid READ guid WRITE setGuid ) @@ -132,7 +132,7 @@ friend class ::DatabaseCommand_CreatePlaylist; friend class DynamicPlaylist; public: - ~Playlist(); + virtual ~Playlist(); static Tomahawk::playlist_ptr load( const QString& guid ); @@ -180,28 +180,13 @@ public: void setCreatedOn( uint createdOn ) { m_createdOn = createdOn; } // - virtual QList tracks(); - - virtual int unfilteredTrackCount() const { return m_entries.count(); } - virtual int trackCount() const { return m_entries.count(); } - - virtual bool hasNextItem() { return false; } - virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; } - - virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); } - - virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } - virtual bool shuffled() const { return false; } - - virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} - virtual void setShuffled( bool ) {} - - virtual void setFilter( const QString& /*pattern*/ ) {} QList entriesFromQueries( const QList& queries, bool clearFirst = false ); void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; } PlaylistUpdaterInterface* updater() const { return m_updater; } + Tomahawk::playlistinterface_ptr getPlaylistInterface(); + signals: /// emitted when the playlist revision changes (whenever the playlist changes) void revisionLoaded( Tomahawk::PlaylistRevision ); @@ -221,13 +206,6 @@ signals: /// was deleted, eh? void deleted( const Tomahawk::playlist_ptr& pl ); - void repeatModeChanged( PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - - void nextTrackReady(); public slots: // want to update the playlist from the model? // generate a newrev using uuid() and call this: @@ -291,8 +269,6 @@ private: unsigned int m_createdOn; bool m_shared; - result_ptr m_currentItem; - QList< plentry_ptr > m_initEntries; QList< plentry_ptr > m_entries; @@ -303,9 +279,11 @@ private: bool m_locallyChanged; bool m_deleted; bool m_busy; + + Tomahawk::playlistinterface_ptr m_playlistInterface; }; -}; +} Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > ) diff --git a/src/libtomahawk/playlist/XspfUpdater.cpp b/src/libtomahawk/playlist/XspfUpdater.cpp index fa966f3f7..796efb17e 100644 --- a/src/libtomahawk/playlist/XspfUpdater.cpp +++ b/src/libtomahawk/playlist/XspfUpdater.cpp @@ -20,10 +20,11 @@ #include "playlist.h" #include "utils/xspfloader.h" +#include "tomahawksettings.h" +#include "pipeline.h" +#include "utils/tomahawkutils.h" #include -#include -#include using namespace Tomahawk; @@ -66,46 +67,15 @@ XspfUpdater::playlistLoaded() XSPFLoader* loader = qobject_cast( sender() ); Q_ASSERT( loader ); - QList< query_ptr> oldqueries; - foreach ( const plentry_ptr& ple, playlist()->entries() ) - oldqueries << ple->query(); + QList< query_ptr > tracks; + foreach ( const plentry_ptr ple, playlist()->entries() ) + tracks << ple->query(); - QList< query_ptr > newqueries = loader->entries(); - int sameCount = 0; - QList< query_ptr > tosave = newqueries; - foreach ( const query_ptr& newquery, newqueries ) - { - foreach ( const query_ptr& oldq, oldqueries ) - { - if ( newquery->track() == oldq->track() && - newquery->artist() == oldq->artist() && - newquery->album() == oldq->album() ) - { - sameCount++; - if ( tosave.contains( newquery ) ) - tosave.replace( tosave.indexOf( newquery ), oldq ); + QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries() ); - break; - } - } - } - - // No work to be done if all are the same - if ( oldqueries.size() == newqueries.size() && sameCount == oldqueries.size() ) - return; - - QList el = playlist()->entriesFromQueries( tosave, true ); + QList el = playlist()->entriesFromQueries( mergedTracks, true ); playlist()->createNewRevision( uuid(), playlist()->currentrevision(), el ); -// // if there are any different from the current playlist, clear and use the new one, update -// bool changed = ( queries.size() == playlist()->entries().count() ); -// if ( !changed ) -// { -// foreach( const query_ptr& newSong, queries ) -// { -// if ( !playlist()->entries.contains() ) -// } -// } } void diff --git a/src/libtomahawk/playlist/albumitemdelegate.cpp b/src/libtomahawk/playlist/albumitemdelegate.cpp index 62f90a3ee..7860147af 100644 --- a/src/libtomahawk/playlist/albumitemdelegate.cpp +++ b/src/libtomahawk/playlist/albumitemdelegate.cpp @@ -129,7 +129,8 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QString text; QFont font = opt.font; - QFont boldFont = opt.font; + font.setPixelSize( 11 ); + QFont boldFont = font; boldFont.setBold( true ); QRect textRect = option.rect.adjusted( 0, option.rect.height() - 32, 0, -2 ); @@ -140,6 +141,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, else if ( !item->artist().isNull() ) name = item->artist()->name(); + painter->setFont( boldFont ); bool oneLiner = false; if ( item->album().isNull() || item->album()->artist().isNull() ) oneLiner = true; @@ -149,14 +151,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, if ( oneLiner ) { - painter->setFont( boldFont ); to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); text = painter->fontMetrics().elidedText( name, Qt::ElideRight, textRect.width() - 3 ); painter->drawText( textRect, text, to ); } else { - painter->setFont( boldFont ); to.setAlignment( Qt::AlignHCenter | Qt::AlignTop ); text = painter->fontMetrics().elidedText( item->album()->name(), Qt::ElideRight, textRect.width() - 3 ); painter->drawText( textRect, text, to ); diff --git a/src/libtomahawk/playlist/albumproxymodel.cpp b/src/libtomahawk/playlist/albumproxymodel.cpp index e687a693c..125a81672 100644 --- a/src/libtomahawk/playlist/albumproxymodel.cpp +++ b/src/libtomahawk/playlist/albumproxymodel.cpp @@ -20,6 +20,7 @@ #include +#include "albumproxymodelplaylistinterface.h" #include "artist.h" #include "albumitem.h" #include "query.h" @@ -28,10 +29,7 @@ AlbumProxyModel::AlbumProxyModel( QObject* parent ) : QSortFilterProxyModel( parent ) - , PlaylistInterface( this ) , m_model( 0 ) - , m_repeatMode( PlaylistInterface::NoRepeat ) - , m_shuffled( false ) { setFilterCaseSensitivity( Qt::CaseInsensitive ); setSortCaseSensitivity( Qt::CaseInsensitive ); @@ -61,29 +59,6 @@ AlbumProxyModel::setSourceAlbumModel( AlbumModel* sourceModel ) QSortFilterProxyModel::setSourceModel( sourceModel ); } -QList< Tomahawk::query_ptr > -AlbumProxyModel::tracks() -{ - Q_ASSERT( FALSE ); - QList queries; - return queries; -} - -Tomahawk::result_ptr -AlbumProxyModel::currentItem() const -{ - return Tomahawk::result_ptr(); -} - -void -AlbumProxyModel::setFilter( const QString& pattern ) -{ - qDebug() << Q_FUNC_INFO; - setFilterRegExp( pattern ); - - emit filterChanged( pattern ); -} - bool AlbumProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const @@ -165,10 +140,13 @@ AlbumProxyModel::removeIndexes( const QList& indexes ) } -Tomahawk::result_ptr -AlbumProxyModel::siblingItem( int itemsAway ) +Tomahawk::playlistinterface_ptr +AlbumProxyModel::getPlaylistInterface() { - Q_UNUSED( itemsAway ); - qDebug() << Q_FUNC_INFO; - return Tomahawk::result_ptr( 0 ); + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; } diff --git a/src/libtomahawk/playlist/albumproxymodel.h b/src/libtomahawk/playlist/albumproxymodel.h index d0d0b40ad..9e8cc566d 100644 --- a/src/libtomahawk/playlist/albumproxymodel.h +++ b/src/libtomahawk/playlist/albumproxymodel.h @@ -26,59 +26,38 @@ #include "dllmacro.h" -class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface +class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit AlbumProxyModel( QObject* parent = 0 ); + virtual ~AlbumProxyModel() {} virtual AlbumModel* sourceModel() const { return m_model; } virtual void setSourceAlbumModel( AlbumModel* sourceModel ); virtual void setSourceModel( QAbstractItemModel* sourceModel ); - virtual QList tracks(); - - virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); } - virtual int trackCount() const { return rowCount( QModelIndex() ); } virtual int albumCount() const { return rowCount( QModelIndex() ); } virtual void removeIndex( const QModelIndex& index ); virtual void removeIndexes( const QList& indexes ); - virtual bool hasNextItem() { return true; } - virtual Tomahawk::result_ptr currentItem() const; - virtual Tomahawk::result_ptr siblingItem( int direction ); + virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); } - virtual void setFilter( const QString& pattern ); - - virtual Tomahawk::PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } - virtual bool shuffled() const { return m_shuffled; } - virtual Tomahawk::PlaylistInterface::ViewMode viewMode() const { return Tomahawk::PlaylistInterface::Album; } + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); signals: - void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - void filterChanged( const QString& filter ); - void nextTrackReady(); - -public slots: - virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } - virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } - protected: bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; bool lessThan( const QModelIndex& left, const QModelIndex& right ) const; private: AlbumModel* m_model; - RepeatMode m_repeatMode; - bool m_shuffled; + + Tomahawk::playlistinterface_ptr m_playlistInterface; }; #endif // ALBUMPROXYMODEL_H diff --git a/src/libtomahawk/playlist/albumproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..892abb3fc --- /dev/null +++ b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.cpp @@ -0,0 +1,100 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "albumproxymodelplaylistinterface.h" + +#include "albumproxymodel.h" +#include "artist.h" +#include "albumitem.h" +#include "query.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +AlbumProxyModelPlaylistInterface::AlbumProxyModelPlaylistInterface( AlbumProxyModel *proxyModel ) + : Tomahawk::PlaylistInterface() + , m_proxyModel( proxyModel ) + , m_repeatMode( PlaylistInterface::NoRepeat ) + , m_shuffled( false ) +{ +} + + +AlbumProxyModelPlaylistInterface::~AlbumProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} + + +QList< Tomahawk::query_ptr > +AlbumProxyModelPlaylistInterface::tracks() +{ + Q_ASSERT( FALSE ); + QList queries; + return queries; +} + + +int +AlbumProxyModelPlaylistInterface::unfilteredTrackCount() const +{ + return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->sourceModel()->rowCount( QModelIndex() ) ); +} + + +int +AlbumProxyModelPlaylistInterface::trackCount() const +{ + return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->rowCount( QModelIndex() ) ); +} + + +Tomahawk::result_ptr +AlbumProxyModelPlaylistInterface::currentItem() const +{ + return Tomahawk::result_ptr(); +} + + +QString +AlbumProxyModelPlaylistInterface::filter() const +{ + return ( m_proxyModel.isNull() ? QString() : m_proxyModel.data()->filterRegExp().pattern() ); +} + + +void +AlbumProxyModelPlaylistInterface::setFilter( const QString& pattern ) +{ + qDebug() << Q_FUNC_INFO; + + if ( m_proxyModel.isNull() ) + return; + + m_proxyModel.data()->setFilterRegExp( pattern ); + m_proxyModel.data()->emitFilterChanged( pattern ); +} + + +Tomahawk::result_ptr +AlbumProxyModelPlaylistInterface::siblingItem( int itemsAway ) +{ + Q_UNUSED( itemsAway ); + qDebug() << Q_FUNC_INFO; + return Tomahawk::result_ptr( 0 ); +} diff --git a/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h new file mode 100644 index 000000000..01e34cdc4 --- /dev/null +++ b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h @@ -0,0 +1,77 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef ALBUMPROXYMODELPLAYLISTINTERFACE_H +#define ALBUMPROXYMODELPLAYLISTINTERFACE_H + +#include "playlistinterface.h" +#include "playlist/albummodel.h" + +#include "dllmacro.h" + +class AlbumProxyModel; + +namespace Tomahawk +{ + +class DLLEXPORT AlbumProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + explicit AlbumProxyModelPlaylistInterface( AlbumProxyModel *proxyModel ); + virtual ~AlbumProxyModelPlaylistInterface(); + + virtual QList tracks(); + + virtual int unfilteredTrackCount() const; + virtual int trackCount() const; + + virtual bool hasNextItem() { return true; } + virtual Tomahawk::result_ptr currentItem() const; + virtual Tomahawk::result_ptr siblingItem( int direction ); + + virtual QString filter() const; + virtual void setFilter( const QString& pattern ); + + virtual Tomahawk::PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } + virtual bool shuffled() const { return m_shuffled; } + virtual Tomahawk::PlaylistInterface::ViewMode viewMode() const { return Tomahawk::PlaylistInterface::Album; } + +signals: + void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + + void nextTrackReady(); + +public slots: + virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } + virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } + +private: + QWeakPointer< AlbumProxyModel > m_proxyModel; + RepeatMode m_repeatMode; + bool m_shuffled; +}; + +} //ns + +#endif // ALBUMPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp index d553b88bc..e975116aa 100644 --- a/src/libtomahawk/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -219,7 +219,7 @@ AlbumView::resizeEvent( QResizeEvent* event ) if ( autoFitItems() ) { #ifdef Q_WS_X11 - int scrollbar = !verticalScrollBar()->isVisible() ? verticalScrollBar()->rect().width() : 0; + int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0; #else int scrollbar = verticalScrollBar()->rect().width(); #endif diff --git a/src/libtomahawk/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h index 5599b68e5..993a2fea7 100644 --- a/src/libtomahawk/playlist/albumview.h +++ b/src/libtomahawk/playlist/albumview.h @@ -53,7 +53,7 @@ public: void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); } virtual QString title() const { return m_model->title(); } virtual QString description() const { return m_model->description(); } diff --git a/src/libtomahawk/playlist/artistview.cpp b/src/libtomahawk/playlist/artistview.cpp index df24db5d0..929905f39 100644 --- a/src/libtomahawk/playlist/artistview.cpp +++ b/src/libtomahawk/playlist/artistview.cpp @@ -188,7 +188,7 @@ ArtistView::onItemActivated( const QModelIndex& index ) else if ( !item->result().isNull() && item->result()->isOnline() ) { m_model->setCurrentItem( item->index ); - AudioEngine::instance()->playItem( m_proxyModel, item->result() ); + AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->result() ); } } } @@ -248,9 +248,9 @@ ArtistView::onFilterChanged( const QString& ) if ( selectedIndexes().count() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); - if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() ) + if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() ) { - m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) ); + m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) ); m_overlay->show(); } else @@ -332,7 +332,7 @@ ArtistView::onScrollTimeout() while ( right.isValid() && right.parent().isValid() ) right = right.parent(); - int max = m_proxyModel->trackCount(); + int max = m_proxyModel->getPlaylistInterface()->trackCount(); if ( right.isValid() ) max = right.row() + 1; diff --git a/src/libtomahawk/playlist/artistview.h b/src/libtomahawk/playlist/artistview.h index 623494c21..e67ef37c3 100644 --- a/src/libtomahawk/playlist/artistview.h +++ b/src/libtomahawk/playlist/artistview.h @@ -19,13 +19,15 @@ #ifndef ARTISTVIEW_H #define ARTISTVIEW_H -#include -#include -#include +#include +#include +#include #include "treeproxymodel.h" #include "viewpage.h" +#include "playlistinterface.h" + #include "dllmacro.h" namespace Tomahawk @@ -60,7 +62,7 @@ public: void setTreeModel( TreeModel* model ); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); } virtual QString title() const { return m_model->title(); } virtual QString description() const { return m_model->description(); } diff --git a/src/libtomahawk/playlist/collectionproxymodel.cpp b/src/libtomahawk/playlist/collectionproxymodel.cpp index dc050511c..1f5df9c7d 100644 --- a/src/libtomahawk/playlist/collectionproxymodel.cpp +++ b/src/libtomahawk/playlist/collectionproxymodel.cpp @@ -18,6 +18,8 @@ #include "collectionproxymodel.h" +#include "collectionproxymodelplaylistinterface.h" + #include #include "album.h" @@ -29,3 +31,14 @@ CollectionProxyModel::CollectionProxyModel( QObject* parent ) : TrackProxyModel( parent ) { } + +Tomahawk::playlistinterface_ptr +CollectionProxyModel::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::CollectionProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist/collectionproxymodel.h b/src/libtomahawk/playlist/collectionproxymodel.h index 61abd3df4..898f05095 100644 --- a/src/libtomahawk/playlist/collectionproxymodel.h +++ b/src/libtomahawk/playlist/collectionproxymodel.h @@ -20,6 +20,7 @@ #define COLLECTIONPROXYMODEL_H #include "trackproxymodel.h" +#include "trackproxymodelplaylistinterface.h" #include "dllmacro.h" @@ -29,8 +30,10 @@ Q_OBJECT public: explicit CollectionProxyModel( QObject* parent = 0 ); + virtual ~CollectionProxyModel() {} + + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); - virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Flat; } }; #endif // COLLECTIONPROXYMODEL_H diff --git a/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..d2e67c9f1 --- /dev/null +++ b/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.cpp @@ -0,0 +1,36 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "collectionproxymodelplaylistinterface.h" + +#include "collectionproxymodel.h" +#include "album.h" +#include "query.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +CollectionProxyModelPlaylistInterface::CollectionProxyModelPlaylistInterface( CollectionProxyModel *proxyModel ) + : TrackProxyModelPlaylistInterface( proxyModel ) +{ +} + +CollectionProxyModelPlaylistInterface::~CollectionProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} diff --git a/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.h b/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.h new file mode 100644 index 000000000..008373867 --- /dev/null +++ b/src/libtomahawk/playlist/collectionproxymodelplaylistinterface.h @@ -0,0 +1,45 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef COLLECTIONPROXYMODELPLAYLISTINTERFACE_H +#define COLLECTIONPROXYMODELPLAYLISTINTERFACE_H + +#include "trackproxymodel.h" +#include "trackproxymodelplaylistinterface.h" + +#include "dllmacro.h" + +class CollectionProxyModel; + +namespace Tomahawk +{ + +class DLLEXPORT CollectionProxyModelPlaylistInterface : public TrackProxyModelPlaylistInterface +{ +Q_OBJECT + +public: + explicit CollectionProxyModelPlaylistInterface( CollectionProxyModel* proxyModel ); + virtual ~CollectionProxyModelPlaylistInterface(); + + virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Flat; } +}; + +} //ns + +#endif // COLLECTIONPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlist/collectionview.h b/src/libtomahawk/playlist/collectionview.h index 3109c77d7..ff7471e97 100644 --- a/src/libtomahawk/playlist/collectionview.h +++ b/src/libtomahawk/playlist/collectionview.h @@ -39,7 +39,7 @@ public: virtual void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); } virtual QString title() const { return model()->title(); } virtual QString description() const { return model()->description(); } diff --git a/src/libtomahawk/playlist/customplaylistview.cpp b/src/libtomahawk/playlist/customplaylistview.cpp index ad4496be7..1cb9517cd 100644 --- a/src/libtomahawk/playlist/customplaylistview.cpp +++ b/src/libtomahawk/playlist/customplaylistview.cpp @@ -41,12 +41,12 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c generateTracks(); if ( m_type == SourceLovedTracks ) - connect( m_source.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); + connect( m_source.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); else if ( m_type == AllLovedTracks ) { - connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); + connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); foreach ( const source_ptr& s, SourceList::instance()->sources( true ) ) - connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); + connect( s.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( sourceAdded( Tomahawk::source_ptr ) ) ); } @@ -104,7 +104,10 @@ CustomPlaylistView::generateTracks() void CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks ) { - m_model->append( tracks ); + QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks ); + + m_model->clear(); + m_model->append( newTracks ); } @@ -153,15 +156,17 @@ CustomPlaylistView::pixmap() const void -CustomPlaylistView::reload() +CustomPlaylistView::socialAttributesChanged( const QString& action ) { - m_model->clear(); - generateTracks(); + if ( action == "Love" ) + { + generateTracks(); + } } void CustomPlaylistView::sourceAdded( const source_ptr& s ) { - connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); + connect( s.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); } diff --git a/src/libtomahawk/playlist/customplaylistview.h b/src/libtomahawk/playlist/customplaylistview.h index b7e0b659d..f03ede49b 100644 --- a/src/libtomahawk/playlist/customplaylistview.h +++ b/src/libtomahawk/playlist/customplaylistview.h @@ -54,7 +54,7 @@ public: private slots: void tracksGenerated( QList tracks ); - void reload(); + void socialAttributesChanged( const QString& ); void sourceAdded( const Tomahawk::source_ptr& ); private: diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp index 728503979..02c70eccf 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp @@ -152,7 +152,7 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author, bool autoLoad ) { - dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ) ); + dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ) ); DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad ); connect( cmd, SIGNAL(finished()), dynplaylist.data(), SIGNAL(created()) ); diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h index 6860926c6..103734c76 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h @@ -55,7 +55,7 @@ struct DynQueueItem : RevisionQueueItem RevisionQueueItem( nRev, oRev, e, latest ), type( typ ), controls( ctrls ), mode( m ) {} }; -class DLLEXPORT DynamicPlaylist : public Playlist +class DLLEXPORT DynamicPlaylist : public Tomahawk::Playlist { Q_OBJECT diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp index dffcdbf49..2cf47020f 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp @@ -98,7 +98,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget connect( m_controls, SIGNAL( controlsChanged( bool ) ), this, SLOT( controlsChanged( bool ) ), Qt::QueuedConnection ); connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( trackStarted() ) ); - connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) ); + connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) ); } @@ -200,10 +200,10 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev ) } -PlaylistInterface* +Tomahawk::playlistinterface_ptr DynamicWidget::playlistInterface() const { - return m_view->proxyModel(); + return m_view->proxyModel()->getPlaylistInterface(); } @@ -241,9 +241,9 @@ DynamicWidget::layoutFloatingWidgets() void -DynamicWidget::playlistChanged( PlaylistInterface* pl ) +DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl ) { - if( pl == static_cast< PlaylistInterface* >( m_view->proxyModel() ) ) { // same playlist + if( pl == m_view->proxyModel()->getPlaylistInterface() ) { // same playlist m_activePlaylist = true; } else { m_activePlaylist = false; diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h index 659e42963..66f24022c 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h @@ -62,7 +62,7 @@ public: void loadDynamicPlaylist( const dynplaylist_ptr& playlist ); dynplaylist_ptr playlist(); - virtual PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QSize sizeHint() const; virtual void resizeEvent( QResizeEvent* ); @@ -88,7 +88,7 @@ public slots: void trackStarted(); void stationFailed( const QString& ); - void playlistChanged( Tomahawk::PlaylistInterface* ); + void playlistChanged( Tomahawk::playlistinterface_ptr ); void tracksAdded(); signals: diff --git a/src/libtomahawk/playlist/playlistitemdelegate.cpp b/src/libtomahawk/playlist/playlistitemdelegate.cpp index f0b38237f..c1ba1b8b9 100644 --- a/src/libtomahawk/playlist/playlistitemdelegate.cpp +++ b/src/libtomahawk/playlist/playlistitemdelegate.cpp @@ -79,7 +79,10 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel { int style = index.data( TrackModel::StyleRole ).toInt(); if ( style == TrackModel::Short || style == TrackModel::ShortWithAvatars ) - size.setHeight( 44 ); + { + int rowHeight = option.fontMetrics.height() + 8; + size.setHeight( rowHeight * 2 ); + } } return size; @@ -235,8 +238,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem& QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption ); - - painter->setFont( opt.font); + painter->setFont( opt.font ); text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption ); } diff --git a/src/libtomahawk/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp index 87f6cfca9..99cf1a3a4 100644 --- a/src/libtomahawk/playlist/playlistmodel.cpp +++ b/src/libtomahawk/playlist/playlistmodel.cpp @@ -152,7 +152,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album ) m_isTemporary = true; } - append( album->tracks() ); + append( album->getPlaylistInterface()->tracks() ); } @@ -172,7 +172,7 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist ) m_isTemporary = true; } - append( artist->tracks() ); + append( artist->getPlaylistInterface()->tracks() ); } @@ -229,7 +229,7 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row ) TrackModelItem* plitem; foreach( const plentry_ptr& entry, entries ) { - plitem = new TrackModelItem( entry, m_rootItem, row + i ); + plitem = new TrackModelItem( entry, rootItem(), row + i ); plitem->index = createIndex( row + i, 0, plitem ); i++; diff --git a/src/libtomahawk/playlist/playlistproxymodel.cpp b/src/libtomahawk/playlist/playlistproxymodel.cpp index 45c234980..ded13bd95 100644 --- a/src/libtomahawk/playlist/playlistproxymodel.cpp +++ b/src/libtomahawk/playlist/playlistproxymodel.cpp @@ -18,6 +18,7 @@ #include "playlistproxymodel.h" +#include "playlistproxymodelplaylistinterface.h" #include "utils/logger.h" @@ -25,3 +26,14 @@ PlaylistProxyModel::PlaylistProxyModel( QObject* parent ) : TrackProxyModel( parent ) { } + +Tomahawk::playlistinterface_ptr +PlaylistProxyModel::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlaylistProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist/playlistproxymodel.h b/src/libtomahawk/playlist/playlistproxymodel.h index f0cddc616..b7e1610db 100644 --- a/src/libtomahawk/playlist/playlistproxymodel.h +++ b/src/libtomahawk/playlist/playlistproxymodel.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -29,6 +29,9 @@ Q_OBJECT public: explicit PlaylistProxyModel( QObject* parent = 0 ); + virtual ~PlaylistProxyModel() {} + + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); }; #endif // PLAYLISTPROXYMODEL_H diff --git a/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..e3b165a7f --- /dev/null +++ b/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.cpp @@ -0,0 +1,34 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "playlistproxymodelplaylistinterface.h" + +#include "playlistproxymodel.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +PlaylistProxyModelPlaylistInterface::PlaylistProxyModelPlaylistInterface( PlaylistProxyModel *proxyModel ) + : TrackProxyModelPlaylistInterface( proxyModel ) +{ +} + +PlaylistProxyModelPlaylistInterface::~PlaylistProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} diff --git a/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.h b/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.h new file mode 100644 index 000000000..4f10c155a --- /dev/null +++ b/src/libtomahawk/playlist/playlistproxymodelplaylistinterface.h @@ -0,0 +1,42 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef PLAYLISTPROXYMODELPLAYLISTINTERFACE_H +#define PLAYLISTPROXYMODELPLAYLISTINTERFACE_H + +#include "trackproxymodelplaylistinterface.h" + +#include "dllmacro.h" + +class PlaylistProxyModel; + +namespace Tomahawk +{ + +class DLLEXPORT PlaylistProxyModelPlaylistInterface : public TrackProxyModelPlaylistInterface +{ +Q_OBJECT + +public: + explicit PlaylistProxyModelPlaylistInterface( PlaylistProxyModel *proxyModel ); + virtual ~PlaylistProxyModelPlaylistInterface(); +}; + +} //ns + +#endif // PLAYLISTPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h index d2b1d56d9..f89836fc3 100644 --- a/src/libtomahawk/playlist/playlistview.h +++ b/src/libtomahawk/playlist/playlistview.h @@ -31,14 +31,14 @@ Q_OBJECT public: explicit PlaylistView( QWidget* parent = 0 ); - ~PlaylistView(); + virtual ~PlaylistView(); PlaylistModel* playlistModel() const { return m_model; } virtual void setPlaylistModel( PlaylistModel* model ); virtual void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); } virtual bool showFilter() const { return true; } diff --git a/src/libtomahawk/playlist/queueproxymodel.cpp b/src/libtomahawk/playlist/queueproxymodel.cpp index 88129a57b..718285fbe 100644 --- a/src/libtomahawk/playlist/queueproxymodel.cpp +++ b/src/libtomahawk/playlist/queueproxymodel.cpp @@ -18,6 +18,7 @@ #include "queueproxymodel.h" +#include "queueproxymodelplaylistinterface.h" #include "playlist/trackview.h" #include "viewmanager.h" #include "utils/logger.h" @@ -31,7 +32,7 @@ QueueProxyModel::QueueProxyModel( TrackView* parent ) qDebug() << Q_FUNC_INFO; connect( parent, SIGNAL( itemActivated( QModelIndex ) ), this, SLOT( onIndexActivated( QModelIndex ) ) ); - connect( this, SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) ); + connect( getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) ); } @@ -48,21 +49,21 @@ QueueProxyModel::onIndexActivated( const QModelIndex& index ) } -Tomahawk::result_ptr -QueueProxyModel::siblingItem( int itemsAway ) -{ - setCurrentIndex( QModelIndex() ); - Tomahawk::result_ptr res = PlaylistProxyModel::siblingItem( itemsAway ); - - remove( currentIndex() ); - - return res; -} - - void QueueProxyModel::onTrackCountChanged( unsigned int count ) { if ( count == 0 ) ViewManager::instance()->hideQueue(); } + + +Tomahawk::playlistinterface_ptr +QueueProxyModel::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::QueueProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist/queueproxymodel.h b/src/libtomahawk/playlist/queueproxymodel.h index d9368648d..5197d443a 100644 --- a/src/libtomahawk/playlist/queueproxymodel.h +++ b/src/libtomahawk/playlist/queueproxymodel.h @@ -32,11 +32,9 @@ Q_OBJECT public: explicit QueueProxyModel( TrackView* parent = 0 ); - ~QueueProxyModel(); + virtual ~QueueProxyModel(); - virtual Tomahawk::result_ptr siblingItem( int itemsAway ); - - using PlaylistProxyModel::siblingItem; + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); private slots: void onIndexActivated( const QModelIndex& index ); diff --git a/src/libtomahawk/playlist/queueproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..6b1c86cf8 --- /dev/null +++ b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.cpp @@ -0,0 +1,50 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "queueproxymodelplaylistinterface.h" + +#include "queueproxymodel.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +QueueProxyModelPlaylistInterface::QueueProxyModelPlaylistInterface( QueueProxyModel *proxyModel ) + : PlaylistProxyModelPlaylistInterface( proxyModel ) +{ +} + + +QueueProxyModelPlaylistInterface::~QueueProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} + + +Tomahawk::result_ptr +QueueProxyModelPlaylistInterface::siblingItem( int itemsAway ) +{ + if ( m_proxyModel.isNull() ) + return Tomahawk::result_ptr(); + + m_proxyModel.data()->setCurrentIndex( QModelIndex() ); + Tomahawk::result_ptr res = PlaylistProxyModelPlaylistInterface::siblingItem( itemsAway ); + + m_proxyModel.data()->remove( m_proxyModel.data()->currentIndex() ); + + return res; +} diff --git a/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h new file mode 100644 index 000000000..85c9101c6 --- /dev/null +++ b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h @@ -0,0 +1,44 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef QUEUEPROXYMODELPLAYLISTINTERFACE_H +#define QUEUEPROXYMODELPLAYLISTINTERFACE_H + +#include "playlistproxymodelplaylistinterface.h" + +#include "dllmacro.h" + +class QueueProxyModel; + +namespace Tomahawk +{ + +class DLLEXPORT QueueProxyModelPlaylistInterface : public PlaylistProxyModelPlaylistInterface +{ +Q_OBJECT + +public: + explicit QueueProxyModelPlaylistInterface( QueueProxyModel *proxyModel ); + virtual ~QueueProxyModelPlaylistInterface(); + + virtual Tomahawk::result_ptr siblingItem( int itemsAway ); +}; + +} //ns + +#endif // QUEUEPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp index e69c1a4b8..6461471b4 100644 --- a/src/libtomahawk/playlist/trackmodel.cpp +++ b/src/libtomahawk/playlist/trackmodel.cpp @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2011 Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -336,6 +337,21 @@ TrackModel::clear() } +QList< query_ptr > +TrackModel::queries() const +{ + Q_ASSERT( m_rootItem ); + + QList< query_ptr > tracks; + foreach ( TrackModelItem* item, m_rootItem->children ) + { + tracks << item->query(); + } + + return tracks; +} + + void TrackModel::append( const Tomahawk::query_ptr& query ) { diff --git a/src/libtomahawk/playlist/trackmodel.h b/src/libtomahawk/playlist/trackmodel.h index f0b4990ea..1850d541a 100644 --- a/src/libtomahawk/playlist/trackmodel.h +++ b/src/libtomahawk/playlist/trackmodel.h @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2011 Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,7 +94,8 @@ public: virtual void ensureResolved(); TrackModelItem* itemFromIndex( const QModelIndex& index ) const; - TrackModelItem* m_rootItem; + /// Returns a flat list of all tracks in this model + QList< Tomahawk::query_ptr > queries() const; signals: void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); @@ -125,11 +127,15 @@ public slots: virtual void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode /*mode*/ ) {} virtual void setShuffled( bool /*shuffled*/ ) {} +protected: + TrackModelItem* rootItem() const { return m_rootItem; } + private slots: void onPlaybackStarted( const Tomahawk::result_ptr& result ); void onPlaybackStopped(); private: + TrackModelItem* m_rootItem; QPersistentModelIndex m_currentIndex; Tomahawk::QID m_currentUuid; diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp index e2753a04f..d78073df3 100644 --- a/src/libtomahawk/playlist/trackproxymodel.cpp +++ b/src/libtomahawk/playlist/trackproxymodel.cpp @@ -20,6 +20,7 @@ #include +#include "trackproxymodelplaylistinterface.h" #include "artist.h" #include "album.h" #include "query.h" @@ -28,10 +29,7 @@ TrackProxyModel::TrackProxyModel( QObject* parent ) : QSortFilterProxyModel( parent ) - , PlaylistInterface( this ) , m_model( 0 ) - , m_repeatMode( PlaylistInterface::NoRepeat ) - , m_shuffled( false ) , m_showOfflineResults( true ) { setFilterCaseSensitivity( Qt::CaseInsensitive ); @@ -57,126 +55,12 @@ TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel ) m_model = sourceModel; if ( m_model && m_model->metaObject()->indexOfSignal( "trackCountChanged(uint)" ) > -1 ) - connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) ); + connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ) ); QSortFilterProxyModel::setSourceModel( m_model ); } -void -TrackProxyModel::setFilter( const QString& pattern ) -{ - PlaylistInterface::setFilter( pattern ); - setFilterRegExp( pattern ); - - emit filterChanged( pattern ); - emit trackCountChanged( trackCount() ); -} - - -QList< Tomahawk::query_ptr > -TrackProxyModel::tracks() -{ - QList queries; - - for ( int i = 0; i < rowCount( QModelIndex() ); i++ ) - { - TrackModelItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) ); - if ( item ) - queries << item->query(); - } - - return queries; -} - - -Tomahawk::result_ptr -TrackProxyModel::siblingItem( int itemsAway ) -{ - return siblingItem( itemsAway, false ); -} - - -bool -TrackProxyModel::hasNextItem() -{ - return !( siblingItem( 1, true ).isNull() ); -} - - -Tomahawk::result_ptr -TrackProxyModel::siblingItem( int itemsAway, bool readOnly ) -{ - qDebug() << Q_FUNC_INFO; - - QModelIndex idx = index( 0, 0 ); - if ( rowCount() ) - { - if ( m_shuffled ) - { - // random mode is enabled - // TODO come up with a clever random logic, that keeps track of previously played items - idx = index( qrand() % rowCount(), 0 ); - } - else if ( currentIndex().isValid() ) - { - idx = currentIndex(); - - // random mode is disabled - if ( m_repeatMode != PlaylistInterface::RepeatOne ) - { - // keep progressing through the playlist normally - idx = index( idx.row() + itemsAway, 0 ); - } - } - } - - if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll ) - { - // repeat all tracks - if ( itemsAway > 0 ) - { - // reset to first item - idx = index( 0, 0 ); - } - else - { - // reset to last item - idx = index( rowCount() - 1, 0 ); - } - } - - // Try to find the next available PlaylistItem (with results) - while ( idx.isValid() ) - { - TrackModelItem* item = itemFromIndex( mapToSource( idx ) ); - if ( item && item->query()->playable() ) - { - qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url(); - if ( !readOnly ) - setCurrentIndex( idx ); - return item->query()->results().at( 0 ); - } - - idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 ); - } - - if ( !readOnly ) - setCurrentIndex( QModelIndex() ); - return Tomahawk::result_ptr(); -} - - -Tomahawk::result_ptr -TrackProxyModel::currentItem() const -{ - TrackModelItem* item = itemFromIndex( mapToSource( currentIndex() ) ); - if ( item && !item->query().isNull() && item->query()->playable() ) - return item->query()->results().at( 0 ); - return Tomahawk::result_ptr(); -} - - bool TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { @@ -388,3 +272,15 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c return QString::localeAwareCompare( lefts, rights ) < 0; } + + +Tomahawk::playlistinterface_ptr +TrackProxyModel::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::TrackProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist/trackproxymodel.h b/src/libtomahawk/playlist/trackproxymodel.h index 862929965..18f3a127a 100644 --- a/src/libtomahawk/playlist/trackproxymodel.h +++ b/src/libtomahawk/playlist/trackproxymodel.h @@ -19,19 +19,20 @@ #ifndef TRACKPROXYMODEL_H #define TRACKPROXYMODEL_H -#include +#include #include "playlistinterface.h" #include "playlist/trackmodel.h" #include "dllmacro.h" -class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface +class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit TrackProxyModel ( QObject* parent = 0 ); + virtual ~TrackProxyModel() {} virtual TrackModel* sourceModel() const { return m_model; } virtual void setSourceTrackModel( TrackModel* sourceModel ); @@ -40,55 +41,29 @@ public: virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); } virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); } - virtual QList tracks(); - - virtual int unfilteredTrackCount() const { return sourceModel()->trackCount(); } - virtual int trackCount() const { return rowCount( QModelIndex() ); } - virtual void remove( const QModelIndex& index ); virtual void remove( const QModelIndexList& indexes ); virtual void remove( const QList< QPersistentModelIndex >& indexes ); - virtual Tomahawk::result_ptr currentItem() const; - virtual Tomahawk::result_ptr siblingItem( int itemsAway ); - virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly ); - virtual bool hasNextItem(); + virtual bool showOfflineResults() const { return m_showOfflineResults; } + virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; } - virtual QString filter() const { return filterRegExp().pattern(); } - virtual void setFilter( const QString& pattern ); + virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); } - virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } - virtual bool shuffled() const { return m_shuffled; } + virtual TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); } - bool showOfflineResults() const { return m_showOfflineResults; } - void setShowOfflineResults( bool b ) { m_showOfflineResults = b; } - - TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); } + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); signals: - void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - void filterChanged( const QString& filter ); - void nextTrackReady(); - -public slots: - virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } - virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } - protected: - bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; - bool lessThan( const QModelIndex& left, const QModelIndex& right ) const; + virtual bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; + virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const; -private: TrackModel* m_model; - RepeatMode m_repeatMode; - bool m_shuffled; bool m_showOfflineResults; + Tomahawk::playlistinterface_ptr m_playlistInterface; }; #endif // TRACKPROXYMODEL_H diff --git a/src/libtomahawk/playlist/trackproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..cceb60ed1 --- /dev/null +++ b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.cpp @@ -0,0 +1,193 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "trackproxymodelplaylistinterface.h" + +#include "trackproxymodel.h" +#include "artist.h" +#include "album.h" +#include "query.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +TrackProxyModelPlaylistInterface::TrackProxyModelPlaylistInterface( TrackProxyModel* proxyModel ) + : PlaylistInterface() + , m_proxyModel( proxyModel ) + , m_repeatMode( PlaylistInterface::NoRepeat ) + , m_shuffled( false ) +{ +} + + +TrackProxyModelPlaylistInterface::~TrackProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} + + +int +TrackProxyModelPlaylistInterface::unfilteredTrackCount() const +{ + return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->sourceModel()->trackCount() ); +} + + +int +TrackProxyModelPlaylistInterface::trackCount() const +{ + return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->rowCount( QModelIndex() ) ); +} + + +QString +TrackProxyModelPlaylistInterface::filter() const +{ + return ( m_proxyModel.isNull() ? QString() : m_proxyModel.data()->filterRegExp().pattern() ); +} + + +void +TrackProxyModelPlaylistInterface::setFilter( const QString& pattern ) +{ + if ( m_proxyModel.isNull() ) + return; + + m_proxyModel.data()->setFilterRegExp( pattern ); + m_proxyModel.data()->emitFilterChanged( pattern ); + + emit trackCountChanged( trackCount() ); +} + + +QList< Tomahawk::query_ptr > +TrackProxyModelPlaylistInterface::tracks() +{ + if ( m_proxyModel.isNull() ) + return QList< Tomahawk::query_ptr >(); + + TrackProxyModel* proxyModel = m_proxyModel.data(); + QList queries; + + for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ ) + { + TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) ); + if ( item ) + queries << item->query(); + } + + return queries; +} + + +Tomahawk::result_ptr +TrackProxyModelPlaylistInterface::siblingItem( int itemsAway ) +{ + return siblingItem( itemsAway, false ); +} + + +bool +TrackProxyModelPlaylistInterface::hasNextItem() +{ + return !( siblingItem( 1, true ).isNull() ); +} + + +Tomahawk::result_ptr +TrackProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly ) +{ + qDebug() << Q_FUNC_INFO; + + if ( m_proxyModel.isNull() ) + return Tomahawk::result_ptr(); + + TrackProxyModel* proxyModel = m_proxyModel.data(); + + QModelIndex idx = proxyModel->index( 0, 0 ); + if ( proxyModel->rowCount() ) + { + if ( m_shuffled ) + { + // random mode is enabled + // TODO come up with a clever random logic, that keeps track of previously played items + idx = proxyModel->index( qrand() % proxyModel->rowCount(), 0 ); + } + else if ( proxyModel->currentIndex().isValid() ) + { + idx = proxyModel->currentIndex(); + + // random mode is disabled + if ( m_repeatMode != PlaylistInterface::RepeatOne ) + { + // keep progressing through the playlist normally + idx = proxyModel->index( idx.row() + itemsAway, 0 ); + } + } + } + + if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll ) + { + // repeat all tracks + if ( itemsAway > 0 ) + { + // reset to first item + idx = proxyModel->index( 0, 0 ); + } + else + { + // reset to last item + idx = proxyModel->index( proxyModel->rowCount() - 1, 0 ); + } + } + + // Try to find the next available PlaylistItem (with results) + while ( idx.isValid() ) + { + TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) ); + if ( item && item->query()->playable() ) + { + qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url(); + if ( !readOnly ) + proxyModel->setCurrentIndex( idx ); + return item->query()->results().at( 0 ); + } + + idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 ); + } + + if ( !readOnly ) + proxyModel->setCurrentIndex( QModelIndex() ); + return Tomahawk::result_ptr(); +} + + +Tomahawk::result_ptr +TrackProxyModelPlaylistInterface::currentItem() const +{ + if ( m_proxyModel.isNull() ) + return Tomahawk::result_ptr(); + + TrackProxyModel* proxyModel = m_proxyModel.data(); + + TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) ); + if ( item && !item->query().isNull() && item->query()->playable() ) + return item->query()->results().at( 0 ); + return Tomahawk::result_ptr(); +} + diff --git a/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h new file mode 100644 index 000000000..afd5bdfb0 --- /dev/null +++ b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h @@ -0,0 +1,69 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TRACKPROXYMODELPLAYLISTINTERFACE_H +#define TRACKPROXYMODELPLAYLISTINTERFACE_H + +#include + +#include "playlistinterface.h" +#include "playlist/trackmodel.h" + +#include "dllmacro.h" + +class TrackProxyModel; + +namespace Tomahawk { + +class DLLEXPORT TrackProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + explicit TrackProxyModelPlaylistInterface( TrackProxyModel* proxyModel ); + virtual ~TrackProxyModelPlaylistInterface(); + + virtual QList tracks(); + + virtual int unfilteredTrackCount() const; + virtual int trackCount() const; + + virtual Tomahawk::result_ptr currentItem() const; + virtual Tomahawk::result_ptr siblingItem( int itemsAway ); + virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly ); + virtual bool hasNextItem(); + + virtual QString filter() const; + virtual void setFilter( const QString& pattern ); + + virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } + virtual bool shuffled() const { return m_shuffled; } + +public slots: + virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } + virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } + +protected: + QWeakPointer< TrackProxyModel > m_proxyModel; + RepeatMode m_repeatMode; + bool m_shuffled; +}; + +} //ns + +#endif // TRACKPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp index 840f8d131..0bbdcd5fe 100644 --- a/src/libtomahawk/playlist/trackview.cpp +++ b/src/libtomahawk/playlist/trackview.cpp @@ -182,7 +182,7 @@ TrackView::onItemActivated( const QModelIndex& index ) { tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url(); m_proxyModel->setCurrentIndex( index ); - AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() ); + AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->query()->results().first() ); } emit itemActivated( index ); @@ -369,9 +369,9 @@ TrackView::onFilterChanged( const QString& ) if ( selectedIndexes().count() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); - if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() ) + if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() ) { - m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) ); + m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) ); m_overlay->show(); } else diff --git a/src/libtomahawk/playlist/trackview.h b/src/libtomahawk/playlist/trackview.h index dc7df9d35..45bb1b23c 100644 --- a/src/libtomahawk/playlist/trackview.h +++ b/src/libtomahawk/playlist/trackview.h @@ -19,8 +19,8 @@ #ifndef TRACKVIEW_H #define TRACKVIEW_H -#include -#include +#include +#include #include "contextmenu.h" #include "playlistitemdelegate.h" diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index 7bd956e4b..10ef415fb 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -18,8 +18,9 @@ #include "treeproxymodel.h" -#include +#include +#include "treeproxymodelplaylistinterface.h" #include "source.h" #include "query.h" #include "database/database.h" @@ -30,11 +31,8 @@ TreeProxyModel::TreeProxyModel( QObject* parent ) : QSortFilterProxyModel( parent ) - , PlaylistInterface( this ) , m_artistsFilterCmd( 0 ) , m_model( 0 ) - , m_repeatMode( PlaylistInterface::NoRepeat ) - , m_shuffled( false ) { setFilterCaseSensitivity( Qt::CaseInsensitive ); setSortCaseSensitivity( Qt::CaseInsensitive ); @@ -111,9 +109,8 @@ TreeProxyModel::onModelReset() m_albumsFilter.clear(); } - void -TreeProxyModel::setFilter( const QString& pattern ) +TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern ) { emit filteringStarted(); @@ -145,7 +142,6 @@ TreeProxyModel::setFilter( const QString& pattern ) } } - void TreeProxyModel::onFilterArtists( const QList& artists ) { @@ -191,15 +187,16 @@ TreeProxyModel::filterFinished() { m_artistsFilterCmd = 0; - if ( PlaylistInterface::filter() != m_filter ) + if ( qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface.data() )->vanillaFilter() != m_filter ) { emit filterChanged( m_filter ); } - PlaylistInterface::setFilter( m_filter ); + qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->setVanillaFilter( m_filter ); setFilterRegExp( m_filter ); - emit trackCountChanged( trackCount() ); + qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->sendTrackCount(); + emit filteringFinished(); } @@ -338,82 +335,6 @@ TreeProxyModel::removeIndexes( const QList& indexes ) } -bool -TreeProxyModel::hasNextItem() -{ - return !( siblingItem( 1, true ).isNull() ); -} - - -Tomahawk::result_ptr -TreeProxyModel::siblingItem( int itemsAway ) -{ - return siblingItem( itemsAway, false ); -} - - -Tomahawk::result_ptr -TreeProxyModel::siblingItem( int itemsAway, bool readOnly ) -{ - QModelIndex idx = currentIndex(); - if ( !idx.isValid() ) - return Tomahawk::result_ptr(); - - if ( m_shuffled ) - { - idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() ); - } - else - { - if ( m_repeatMode != PlaylistInterface::RepeatOne ) - idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); - } - - if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll ) - { - if ( itemsAway > 0 ) - { - // reset to first item - idx = index( 0, 0, currentIndex().parent() ); - } - else - { - // reset to last item - idx = index( rowCount( currentIndex().parent() ) - 1, 0, currentIndex().parent() ); - } - } - - // Try to find the next available PlaylistItem (with results) - while ( idx.isValid() ) - { - TreeModelItem* item = itemFromIndex( mapToSource( idx ) ); - if ( item && !item->result().isNull() && item->result()->isOnline() ) - { - qDebug() << "Next PlaylistItem found:" << item->result()->url(); - if ( !readOnly ) - setCurrentIndex( idx ); - return item->result(); - } - - idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); - } - - if ( !readOnly ) - setCurrentIndex( QModelIndex() ); - return Tomahawk::result_ptr(); -} - - -Tomahawk::result_ptr -TreeProxyModel::currentItem() const -{ - TreeModelItem* item = itemFromIndex( mapToSource( currentIndex() ) ); - if ( item && !item->result().isNull() && item->result()->isOnline() ) - return item->result(); - return Tomahawk::result_ptr(); -} - - QString TreeProxyModel::textForItem( TreeModelItem* item ) const { @@ -439,3 +360,15 @@ TreeProxyModel::textForItem( TreeModelItem* item ) const return QString(); } + + +Tomahawk::playlistinterface_ptr +TreeProxyModel::getPlaylistInterface() +{ + if ( m_playlistInterface.isNull() ) + { + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::TreeProxyModelPlaylistInterface( this ) ); + } + + return m_playlistInterface; +} diff --git a/src/libtomahawk/playlist/treeproxymodel.h b/src/libtomahawk/playlist/treeproxymodel.h index 84f09bcdb..6ce52785a 100644 --- a/src/libtomahawk/playlist/treeproxymodel.h +++ b/src/libtomahawk/playlist/treeproxymodel.h @@ -28,12 +28,18 @@ class DatabaseCommand_AllArtists; -class DLLEXPORT TreeProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface +namespace Tomahawk +{ + class TreeProxyModelPlaylistInterface; +} + +class DLLEXPORT TreeProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit TreeProxyModel( QObject* parent = 0 ); + virtual ~TreeProxyModel() {} virtual TreeModel* sourceModel() const { return m_model; } virtual void setSourceTreeModel( TreeModel* sourceModel ); @@ -42,46 +48,22 @@ public: virtual QPersistentModelIndex currentIndex() const; virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); } - virtual QList tracks() { Q_ASSERT( FALSE ); QList queries; return queries; } - - virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); } - virtual int trackCount() const { return rowCount( QModelIndex() ); } - virtual int albumCount() const { return rowCount( QModelIndex() ); } + virtual void newFilterFromPlaylistInterface( const QString &pattern ); virtual void removeIndex( const QModelIndex& index ); virtual void removeIndexes( const QList& indexes ); - virtual bool hasNextItem(); - virtual Tomahawk::result_ptr currentItem() const; - virtual Tomahawk::result_ptr siblingItem( int direction ); - virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly ); + virtual int albumCount() const { return rowCount( QModelIndex() ); } - virtual QString filter() const { return filterRegExp().pattern(); } - virtual void setFilter( const QString& pattern ); + virtual TreeModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); } - virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } - virtual bool shuffled() const { return m_shuffled; } - virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Tree; } - - TreeModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); } + virtual Tomahawk::playlistinterface_ptr getPlaylistInterface(); signals: - void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); - void shuffleModeChanged( bool enabled ); - - void trackCountChanged( unsigned int tracks ); - void sourceTrackCountChanged( unsigned int tracks ); - void filterChanged( const QString& filter ); void filteringStarted(); void filteringFinished(); - void nextTrackReady(); - -public slots: - virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } - virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } - protected: bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; bool lessThan( const QModelIndex& left, const QModelIndex& right ) const; @@ -104,11 +86,11 @@ private: QList m_albumsFilter; DatabaseCommand_AllArtists* m_artistsFilterCmd; - QString m_filter; + QString m_filter; TreeModel* m_model; - RepeatMode m_repeatMode; - bool m_shuffled; + + Tomahawk::playlistinterface_ptr m_playlistInterface; }; #endif // TREEPROXYMODEL_H diff --git a/src/libtomahawk/playlist/treeproxymodelplaylistinterface.cpp b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.cpp new file mode 100644 index 000000000..0521ad42b --- /dev/null +++ b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.cpp @@ -0,0 +1,167 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "treeproxymodelplaylistinterface.h" + +#include "treeproxymodel.h" + +#include "source.h" +#include "query.h" +#include "database/database.h" +#include "database/databaseimpl.h" +#include "database/databasecommand_allalbums.h" +#include "utils/logger.h" + +using namespace Tomahawk; + +TreeProxyModelPlaylistInterface::TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel ) + : PlaylistInterface() + , m_proxyModel( proxyModel ) + , m_repeatMode( PlaylistInterface::NoRepeat ) + , m_shuffled( false ) +{ +} + + +TreeProxyModelPlaylistInterface::~TreeProxyModelPlaylistInterface() +{ + m_proxyModel.clear(); +} + + +QString +TreeProxyModelPlaylistInterface::filter() const +{ + if ( m_proxyModel.isNull() ) + return 0; + TreeProxyModel* proxyModel = m_proxyModel.data(); + return proxyModel->filterRegExp().pattern(); +} + + +void +TreeProxyModelPlaylistInterface::setFilter( const QString& pattern ) +{ + if ( m_proxyModel.isNull() ) + return; + m_proxyModel.data()->newFilterFromPlaylistInterface( pattern ); +} + + +int +TreeProxyModelPlaylistInterface::unfilteredTrackCount() const +{ + if ( m_proxyModel.isNull() ) + return 0; + TreeProxyModel* proxyModel = m_proxyModel.data(); + return proxyModel->sourceModel()->rowCount( QModelIndex() ); +} + + +int +TreeProxyModelPlaylistInterface::trackCount() const +{ + if ( m_proxyModel.isNull() ) + return 0; + TreeProxyModel* proxyModel = m_proxyModel.data(); + return proxyModel->rowCount( QModelIndex() ); +} + + +bool +TreeProxyModelPlaylistInterface::hasNextItem() +{ + return !( siblingItem( 1, true ).isNull() ); +} + + +Tomahawk::result_ptr +TreeProxyModelPlaylistInterface::siblingItem( int itemsAway ) +{ + return siblingItem( itemsAway, false ); +} + + +Tomahawk::result_ptr +TreeProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly ) +{ + if ( m_proxyModel.isNull() ) + return Tomahawk::result_ptr(); + TreeProxyModel* proxyModel = m_proxyModel.data(); + + QModelIndex idx = proxyModel->currentIndex(); + if ( !idx.isValid() ) + return Tomahawk::result_ptr(); + + if ( m_shuffled ) + { + idx = proxyModel->index( qrand() % proxyModel->rowCount( idx.parent() ), 0, idx.parent() ); + } + else + { + if ( m_repeatMode != PlaylistInterface::RepeatOne ) + idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); + } + + if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll ) + { + if ( itemsAway > 0 ) + { + // reset to first item + idx = proxyModel->index( 0, 0, proxyModel->currentIndex().parent() ); + } + else + { + // reset to last item + idx = proxyModel->index( proxyModel->rowCount( proxyModel->currentIndex().parent() ) - 1, 0, proxyModel->currentIndex().parent() ); + } + } + + // Try to find the next available PlaylistItem (with results) + while ( idx.isValid() ) + { + TreeModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) ); + if ( item && !item->result().isNull() && item->result()->isOnline() ) + { + qDebug() << "Next PlaylistItem found:" << item->result()->url(); + if ( !readOnly ) + proxyModel->setCurrentIndex( idx ); + return item->result(); + } + + idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); + } + + if ( !readOnly ) + proxyModel->setCurrentIndex( QModelIndex() ); + return Tomahawk::result_ptr(); +} + + +Tomahawk::result_ptr +TreeProxyModelPlaylistInterface::currentItem() const +{ + if ( m_proxyModel.isNull() ) + return Tomahawk::result_ptr(); + TreeProxyModel* proxyModel = m_proxyModel.data(); + + TreeModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) ); + if ( item && !item->result().isNull() && item->result()->isOnline() ) + return item->result(); + return Tomahawk::result_ptr(); +} diff --git a/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h new file mode 100644 index 000000000..f38654981 --- /dev/null +++ b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h @@ -0,0 +1,89 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TREEPROXYMODELPLAYLISTINTERFACE_H +#define TREEPROXYMODELPLAYLISTINTERFACE_H + +#include "playlistinterface.h" +#include "treemodel.h" + +#include "dllmacro.h" + +class DatabaseCommand_AllArtists; +class TreeProxyModel; + +namespace Tomahawk +{ + +class DLLEXPORT TreeProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + explicit TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel ); + virtual ~TreeProxyModelPlaylistInterface(); + + virtual QList< Tomahawk::query_ptr > tracks() { Q_ASSERT( FALSE ); QList< Tomahawk::query_ptr > queries; return queries; } + + virtual int unfilteredTrackCount() const; + virtual int trackCount() const; + + virtual bool hasNextItem(); + virtual Tomahawk::result_ptr currentItem() const; + virtual Tomahawk::result_ptr siblingItem( int direction ); + virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly ); + + virtual QString filter() const; + virtual void setFilter( const QString& pattern ); + + virtual QString vanillaFilter() const { return PlaylistInterface::filter(); } + virtual void setVanillaFilter( const QString &filter ) { PlaylistInterface::setFilter( filter ); } + + virtual void sendTrackCount() { emit trackCountChanged( trackCount() ); } + + virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } + virtual bool shuffled() const { return m_shuffled; } + virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Tree; } + +signals: + void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + + void filterChanged( const QString& filter ); + void filteringStarted(); + void filteringFinished(); + + void nextTrackReady(); + +public slots: + virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); } + virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); } + +private: + QWeakPointer< TreeProxyModel > m_proxyModel; + + RepeatMode m_repeatMode; + bool m_shuffled; +}; + +} //ns + +#endif // TREEPROXYMODELPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/playlistinterface.cpp b/src/libtomahawk/playlistinterface.cpp index 7724329f2..8c03d9df1 100644 --- a/src/libtomahawk/playlistinterface.cpp +++ b/src/libtomahawk/playlistinterface.cpp @@ -17,13 +17,13 @@ */ #include "playlistinterface.h" - +#include "utils/logger.h" #include "result.h" using namespace Tomahawk; -PlaylistInterface::PlaylistInterface ( QObject *parent ) - : m_object( parent ) +PlaylistInterface::PlaylistInterface () + : QObject() { qRegisterMetaType( "Tomahawk::PlaylistInterface::RepeatMode" ); } diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h index 991a84275..1632e5b66 100644 --- a/src/libtomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -19,7 +19,7 @@ #ifndef PLAYLISTINTERFACE_H #define PLAYLISTINTERFACE_H -#include +#include #include "typedefs.h" #include "dllmacro.h" @@ -28,8 +28,9 @@ namespace Tomahawk { -class DLLEXPORT PlaylistInterface +class DLLEXPORT PlaylistInterface : public QObject { +Q_OBJECT public: enum RepeatMode { NoRepeat, RepeatOne, RepeatAll }; @@ -39,7 +40,7 @@ public: enum SkipRestrictions { NoSkipRestrictions, NoSkipForwards, NoSkipBackwards, NoSkip }; enum RetryMode { NoRetry, Retry }; - explicit PlaylistInterface( QObject* parent = 0 ); + explicit PlaylistInterface(); virtual ~PlaylistInterface(); virtual QList< Tomahawk::query_ptr > tracks() = 0; @@ -67,44 +68,25 @@ public: virtual void reset() {} + //TODO: Get rid of the next two functions once all playlsitinterfaces are factored out // Some playlist interfaces can wrap other interfaces. When checking for top-level // equality (say, to compare the currently playing interface) this might be needed - virtual bool hasChildInterface( PlaylistInterface* ) { return false; } - - QObject* object() const { return m_object; } - - static void dontDelete( Tomahawk::PlaylistInterface* obj ) - { - tDebug() << Q_FUNC_INFO << obj; - } - - virtual Tomahawk::playlistinterface_ptr getSharedPointer() - { - if ( m_sharedPtr.isNull() ) - { - m_sharedPtr = Tomahawk::playlistinterface_ptr( this, dontDelete ); - } - - return m_sharedPtr; - } + virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr ) { return false; } public slots: virtual void setRepeatMode( RepeatMode mode ) = 0; virtual void setShuffled( bool enabled ) = 0; signals: - virtual void repeatModeChanged( PlaylistInterface::RepeatMode mode ) = 0; - virtual void shuffleModeChanged( bool enabled ) = 0; - virtual void trackCountChanged( unsigned int tracks ) = 0; - virtual void sourceTrackCountChanged( unsigned int tracks ) = 0; - virtual void nextTrackReady() = 0; + void repeatModeChanged( PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + void nextTrackReady(); private: Q_DISABLE_COPY( PlaylistInterface ) - QObject* m_object; - Tomahawk::playlistinterface_ptr m_sharedPtr; - QString m_filter; }; diff --git a/src/libtomahawk/playlistplaylistinterface.cpp b/src/libtomahawk/playlistplaylistinterface.cpp new file mode 100644 index 000000000..30049fc0b --- /dev/null +++ b/src/libtomahawk/playlistplaylistinterface.cpp @@ -0,0 +1,64 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "playlistplaylistinterface.h" + +#include "playlist.h" +#include "sourcelist.h" + +#include "utils/logger.h" + +using namespace Tomahawk; + + +PlaylistPlaylistInterface::PlaylistPlaylistInterface( Tomahawk::Playlist* playlist ) + : Tomahawk::PlaylistInterface() + , m_playlist( playlist ) +{ +} + + +PlaylistPlaylistInterface::~PlaylistPlaylistInterface() +{ + m_playlist.clear(); +} + + +int +PlaylistPlaylistInterface::unfilteredTrackCount() const +{ + return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() ); +} + + +int +PlaylistPlaylistInterface::trackCount() const +{ + return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() ); +} + + +QList< Tomahawk::query_ptr > +PlaylistPlaylistInterface::tracks() +{ + QList queries; + foreach( const plentry_ptr& p, ( m_playlist.isNull() ? QList< Tomahawk::plentry_ptr >() : m_playlist.data()->entries() ) ) + queries << p->query(); + + return queries; +} diff --git a/src/libtomahawk/playlistplaylistinterface.h b/src/libtomahawk/playlistplaylistinterface.h new file mode 100644 index 000000000..94dcacd08 --- /dev/null +++ b/src/libtomahawk/playlistplaylistinterface.h @@ -0,0 +1,83 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef PLAYLISTPLAYLISTINTERFACE_H +#define PLAYLISTPLAYLISTINTERFACE_H + +#include +#include +#include + +#include "typedefs.h" +#include "result.h" +#include "playlistinterface.h" +#include "query.h" + +#include "dllmacro.h" + +namespace Tomahawk +{ + +class DLLEXPORT PlaylistPlaylistInterface : public Tomahawk::PlaylistInterface +{ +Q_OBJECT + +public: + PlaylistPlaylistInterface( Tomahawk::Playlist* playlist ); + virtual ~PlaylistPlaylistInterface(); + + virtual QList tracks(); + + virtual int unfilteredTrackCount() const; + virtual int trackCount() const; + + virtual bool hasNextItem() { return false; } + virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; } + + virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); } + + virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } + virtual bool shuffled() const { return false; } + + virtual void setFilter( const QString& /*pattern*/ ) {} + +signals: + void repeatModeChanged( PlaylistInterface::RepeatMode mode ); + void shuffleModeChanged( bool enabled ); + + void trackCountChanged( unsigned int tracks ); + void sourceTrackCountChanged( unsigned int tracks ); + + void nextTrackReady(); + +public slots: + virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {} + virtual void setShuffled( bool ) {} + +private: + PlaylistPlaylistInterface(); + Q_DISABLE_COPY( PlaylistPlaylistInterface ) + + QWeakPointer< Tomahawk::Playlist > m_playlist; + + result_ptr m_currentItem; +}; + +} + +#endif // PLAYLISTPLAYLISTINTERFACE_H diff --git a/src/libtomahawk/resolvers/scriptresolver.cpp b/src/libtomahawk/resolvers/scriptresolver.cpp index 56d027f65..37fd4ec05 100644 --- a/src/libtomahawk/resolvers/scriptresolver.cpp +++ b/src/libtomahawk/resolvers/scriptresolver.cpp @@ -30,6 +30,9 @@ #include "utils/tomahawkutils.h" #include "utils/logger.h" +#ifdef Q_OS_WIN +#include +#endif ScriptResolver::ScriptResolver( const QString& exe ) : Tomahawk::ExternalResolverGui( exe ) @@ -45,24 +48,13 @@ ScriptResolver::ScriptResolver( const QString& exe ) connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) ); connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) ); - QString runPath = filePath(); -#ifdef WIN32 - // have to enclose in quotes if path contains spaces on windows... - runPath = QString( "\"%1\"" ).arg( filePath() ); -#endif - - if ( !QFile::exists( filePath() ) ) - m_error = Tomahawk::ExternalResolver::FileNotFound; - else - m_proc.start( runPath ); + startProcess(); if ( !TomahawkUtils::nam() ) return; // set the name to the binary, if we launch properly we'll get the name the resolver reports m_name = QFileInfo( filePath() ).baseName(); - - sendConfig(); } @@ -141,15 +133,7 @@ ScriptResolver::sendConfig() void ScriptResolver::reload() { - if ( !QFile::exists( filePath() ) ) - m_error = Tomahawk::ExternalResolver::FileNotFound; - else - { - m_error = Tomahawk::ExternalResolver::NoError; - m_proc.start( filePath() ); - - sendConfig(); - } + startProcess(); } @@ -309,7 +293,7 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status ) { m_num_restarts++; tLog() << "*** Restart num" << m_num_restarts; - m_proc.start( filePath() ); + startProcess(); sendConfig(); } else @@ -381,6 +365,58 @@ ScriptResolver::setupConfWidget( const QVariantMap& m ) } +void ScriptResolver::startProcess() +{ + if ( !QFile::exists( filePath() ) ) + m_error = Tomahawk::ExternalResolver::FileNotFound; + else + { + m_error = Tomahawk::ExternalResolver::NoError; + } + + QFileInfo fi( filePath() ); + + QString interpreter; + QString runPath = filePath(); + +#ifdef Q_OS_WIN + if ( fi.suffix().toLower() != "exe" ) + { + DWORD dwSize = MAX_PATH; + + wchar_t path[MAX_PATH] = { 0 }; + wchar_t *ext = (wchar_t *) ("." + fi.suffix()).utf16(); + + HRESULT hr = AssocQueryStringW( + (ASSOCF) 0, + ASSOCSTR_EXECUTABLE, + ext, + L"open", + path, + &dwSize + ); + + if ( ! FAILED( hr ) ) + { + interpreter = QString( "\"%1\"" ).arg(QString::fromUtf16((const ushort *) path)); + } + } + else + { + // have to enclose in quotes if path contains spaces on windows... + runPath = QString( "\"%1\"" ).arg( filePath() ); + } +#endif // Q_OS_WIN + + if( interpreter.isEmpty() ) + m_proc.start( runPath ); + else + m_proc.start( interpreter, QStringList() << filePath() ); + + sendConfig(); +} + + void ScriptResolver::saveConfig() { diff --git a/src/libtomahawk/resolvers/scriptresolver.h b/src/libtomahawk/resolvers/scriptresolver.h index c7cd9a9e4..f8e94b0ff 100644 --- a/src/libtomahawk/resolvers/scriptresolver.h +++ b/src/libtomahawk/resolvers/scriptresolver.h @@ -75,6 +75,8 @@ private: void doSetup( const QVariantMap& m ); void setupConfWidget( const QVariantMap& m ); + void startProcess(); + QProcess m_proc; QString m_name; unsigned int m_weight, m_preference, m_timeout, m_num_restarts; diff --git a/src/libtomahawk/result.h b/src/libtomahawk/result.h index 9b9642922..e7adc4a6e 100644 --- a/src/libtomahawk/result.h +++ b/src/libtomahawk/result.h @@ -19,8 +19,9 @@ #ifndef RESULT_H #define RESULT_H -#include -#include +#include +#include +#include #include "typedefs.h" @@ -125,7 +126,7 @@ private slots: private: // private constructor explicit Result( const QString& url ); - Result(); + explicit Result(); void updateAttributes(); void parseSocialActions(); @@ -156,6 +157,6 @@ private: QList< SocialAction > m_allSocialActions; }; -}; //ns +} //ns #endif // RESULT_H diff --git a/src/libtomahawk/source.cpp b/src/libtomahawk/source.cpp index bf45bd031..575953d07 100644 --- a/src/libtomahawk/source.cpp +++ b/src/libtomahawk/source.cpp @@ -188,7 +188,7 @@ Source::setOffline() m_cc = 0; DatabaseCommand_SourceOffline* cmd = new DatabaseCommand_SourceOffline( id() ); - Database::instance()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); } @@ -307,7 +307,7 @@ Source::getPlaylistInterface() if ( m_playlistInterface.isNull() ) { Tomahawk::source_ptr source = SourceList::instance()->get( id() ); - m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source ) ); + m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source.data() ) ); } return m_playlistInterface; @@ -411,7 +411,9 @@ Source::executeCommands() void Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action ) { - emit socialAttributesChanged(); + Q_ASSERT( action ); + + emit socialAttributesChanged( action->action() ); if ( action->action() == "latchOn" ) { diff --git a/src/libtomahawk/source.h b/src/libtomahawk/source.h index 00a608e96..e502da0b2 100644 --- a/src/libtomahawk/source.h +++ b/src/libtomahawk/source.h @@ -19,9 +19,9 @@ #ifndef SOURCE_H #define SOURCE_H -#include -#include -#include +#include +#include +#include #include "typedefs.h" #include "network/dbsyncconnection.h" @@ -106,7 +106,7 @@ signals: void stateChanged(); void commandsFinished(); - void socialAttributesChanged(); + void socialAttributesChanged( const QString& action ); void latchedOn( const Tomahawk::source_ptr& to ); void latchedOff( const Tomahawk::source_ptr& from ); @@ -162,6 +162,6 @@ private: Tomahawk::playlistinterface_ptr m_playlistInterface; }; -}; +} //ns #endif // SOURCE_H diff --git a/src/libtomahawk/sourceplaylistinterface.cpp b/src/libtomahawk/sourceplaylistinterface.cpp index 28a7abdec..b1ee26ef6 100644 --- a/src/libtomahawk/sourceplaylistinterface.cpp +++ b/src/libtomahawk/sourceplaylistinterface.cpp @@ -26,18 +26,21 @@ using namespace Tomahawk; -SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source ) - : PlaylistInterface( this ) +SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source ) + : PlaylistInterface() , m_source( source ) , m_currentItem( 0 ) , m_gotNextItem( false ) { - connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) ); + if ( !m_source.isNull() ) + connect( m_source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) ); } SourcePlaylistInterface::~SourcePlaylistInterface() -{} +{ + m_source.clear(); +} Tomahawk::result_ptr @@ -52,7 +55,7 @@ Tomahawk::result_ptr SourcePlaylistInterface::nextItem() { tDebug( LOGEXTRA ) << Q_FUNC_INFO; - if ( m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() ) + if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() ) { tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Results were empty for current track or source no longer valid"; m_currentItem = Tomahawk::result_ptr(); @@ -65,7 +68,7 @@ SourcePlaylistInterface::nextItem() } m_gotNextItem = false; - m_currentItem = m_source->currentTrack()->results().first(); + m_currentItem = m_source.data()->currentTrack()->results().first(); return m_currentItem; } @@ -81,7 +84,7 @@ bool SourcePlaylistInterface::hasNextItem() { tDebug( LOGEXTRA ) << Q_FUNC_INFO; - if ( m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() ) + if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() ) return false; return m_gotNextItem; @@ -96,7 +99,7 @@ SourcePlaylistInterface::tracks() } -source_ptr +QWeakPointer< Tomahawk::Source > SourcePlaylistInterface::source() const { return m_source; diff --git a/src/libtomahawk/sourceplaylistinterface.h b/src/libtomahawk/sourceplaylistinterface.h index 1b23f5af3..ce03f3c63 100644 --- a/src/libtomahawk/sourceplaylistinterface.h +++ b/src/libtomahawk/sourceplaylistinterface.h @@ -30,13 +30,13 @@ namespace Tomahawk { -class DLLEXPORT SourcePlaylistInterface : public QObject, public PlaylistInterface +class DLLEXPORT SourcePlaylistInterface : public Tomahawk::PlaylistInterface { Q_OBJECT public: - SourcePlaylistInterface( Tomahawk::source_ptr& source ); - ~SourcePlaylistInterface(); + SourcePlaylistInterface( Tomahawk::Source *source ); + virtual ~SourcePlaylistInterface(); QList tracks(); @@ -57,7 +57,7 @@ public: virtual bool shuffled() const { return false; } virtual void setFilter( const QString& /*pattern*/ ) {} - virtual Tomahawk::source_ptr source() const; + virtual QWeakPointer< Tomahawk::Source > source() const; virtual void reset(); @@ -77,7 +77,7 @@ private slots: void resolvingFinished( bool hasResults ); private: - Tomahawk::source_ptr m_source; + QWeakPointer< Tomahawk::Source > m_source; Tomahawk::result_ptr m_currentItem; bool m_gotNextItem; }; diff --git a/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp b/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp index 6ccfe4e39..1319b6837 100644 --- a/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp +++ b/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp @@ -1,7 +1,7 @@ #include "kdsingleapplicationguard.h" #ifndef KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES -#define KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES 128 +#define KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES 10 #endif #ifndef KDSINGLEAPPLICATIONGUARD_MAX_COMMAND_LINE diff --git a/src/libtomahawk/utils/groovesharkparser.cpp b/src/libtomahawk/utils/groovesharkparser.cpp index 59c898822..dcc28e620 100644 --- a/src/libtomahawk/utils/groovesharkparser.cpp +++ b/src/libtomahawk/utils/groovesharkparser.cpp @@ -2,7 +2,7 @@ * * Copyright 2010-2011, Leo Franchi * Copyright 2010-2011, Hugo Lindström - * Copyright 2010-2011, Stefan Derkits + * Copyright 2010-2012, Stefan Derkits * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,42 +91,56 @@ GroovesharkParser::lookupGroovesharkPlaylist( const QString& linkRaw ) { tLog() << "Parsing Grooveshark Playlist URI:" << linkRaw; - QStringList urlParts = linkRaw.split( "/" ); + QString urlFragment = QUrl( linkRaw ).fragment( ); + if ( urlFragment.isEmpty() ) { + tDebug() << "no fragment, setting fragment to path"; + urlFragment = QUrl(linkRaw).path(); + } + + tDebug() << urlFragment; + + int paramStartingPostition = urlFragment.indexOf( "?" ); + + if ( paramStartingPostition != -1 ) + urlFragment.truncate( paramStartingPostition ); + bool ok; - QString playlistStr = urlParts.last(); - playlistStr.truncate(playlistStr.indexOf("?")); - int playlistID = playlistStr.toInt( &ok, 10 ); + + QStringList urlParts = urlFragment.split( "/", QString::SkipEmptyParts ); + + tDebug() << urlParts; + + int playlistID = urlParts.at( 2 ).toInt( &ok, 10 ); if (!ok) { tDebug() << "incorrect grooveshark url"; return; } - m_title = urlParts.at( urlParts.size()-2 ); + + + m_title = urlParts.at( 1 ); tDebug() << "should get playlist " << playlistID; DropJob::DropType type; - if ( linkRaw.contains( "playlist" ) ) - type = DropJob::Playlist; + type = DropJob::Playlist; QString base_url( "http://api.grooveshark.com/ws3.php?sig=" ); QByteArray data = QString( "{\"method\":\"getPlaylistSongs\",\"parameters\":{\"playlistID\":\"%1\"},\"header\":{\"wsKey\":\"tomahawkplayer\"}}" ).arg( playlistID ).toLocal8Bit(); - - - - + + QCA::MessageAuthenticationCode hmac( "hmac(md5)", m_apiKey ); QCA::SecureArray secdata( data ); hmac.update(secdata); QCA::SecureArray resultArray = hmac.final(); - + QString hash = QCA::arrayToHex( resultArray.toByteArray() ); QUrl url = QUrl( base_url + hash ); - + tDebug() << "Looking up URL..." << url.toString(); QNetworkReply* reply = TomahawkUtils::nam()->post( QNetworkRequest( url ), data ); diff --git a/src/libtomahawk/utils/shortenedlinkparser.cpp b/src/libtomahawk/utils/shortenedlinkparser.cpp index 6c37f951e..6d89aba69 100644 --- a/src/libtomahawk/utils/shortenedlinkparser.cpp +++ b/src/libtomahawk/utils/shortenedlinkparser.cpp @@ -35,7 +35,8 @@ ShortenedLinkParser::ShortenedLinkParser ( const QStringList& urls, QObject* par : QObject( parent ) { foreach ( const QString& url, urls ) - lengthenUrl( url ); + if ( handlesUrl( url ) ) + lookupUrl( url ) ; } @@ -60,13 +61,9 @@ ShortenedLinkParser::handlesUrl( const QString& url ) url.contains( "rd.io" ) ); } - void -ShortenedLinkParser::lengthenUrl( const QString& url ) +ShortenedLinkParser::lookupUrl ( const QString& url ) { - if ( !handlesUrl( url ) ) - return; - tDebug() << "Looking up..." << url; QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( url ) ) ); @@ -75,7 +72,6 @@ ShortenedLinkParser::lengthenUrl( const QString& url ) m_queries.insert( reply ); } - void ShortenedLinkParser::lookupFinished() { @@ -85,14 +81,19 @@ ShortenedLinkParser::lookupFinished() QVariant redir = r->attribute( QNetworkRequest::RedirectionTargetAttribute ); if ( redir.isValid() && !redir.toUrl().isEmpty() ) { - tLog() << "Got a redirected url:" << redir.toUrl().toString(); - m_links << redir.toUrl().toString(); + tDebug() << "RedirectionTargetAttribute set on " << redir; + m_queries.remove( r ); + r->deleteLater(); + lookupUrl( redir.toUrl().toString() ); + } + else + { + tLog() << "Got a redirected url:" << r->url().toString(); + m_links << r->url().toString(); + m_queries.remove( r ); + r->deleteLater(); + checkFinished(); } - - r->deleteLater(); - - m_queries.remove( r ); - checkFinished(); } diff --git a/src/libtomahawk/utils/shortenedlinkparser.h b/src/libtomahawk/utils/shortenedlinkparser.h index 51c208725..4fd358749 100644 --- a/src/libtomahawk/utils/shortenedlinkparser.h +++ b/src/libtomahawk/utils/shortenedlinkparser.h @@ -55,7 +55,7 @@ signals: void urls( const QStringList& urls ); private: - void lengthenUrl( const QString& url ); + void lookupUrl( const QString& url ); void checkFinished(); QStringList m_links; diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index b0a17dd3a..367164955 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -532,6 +532,36 @@ newerVersion( const QString& oldVersion, const QString& newVersion ) } +QList< Tomahawk::query_ptr > +mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks ) +{ + int sameCount = 0; + QList< Tomahawk::query_ptr > tosave = newTracks; + foreach ( const Tomahawk::query_ptr& newquery, newTracks ) + { + foreach ( const Tomahawk::query_ptr& oldq, orig ) + { + if ( newquery->track() == oldq->track() && + newquery->artist() == oldq->artist() && + newquery->album() == oldq->album() ) + { + sameCount++; + if ( tosave.contains( newquery ) ) + tosave.replace( tosave.indexOf( newquery ), oldq ); + + break; + } + } + } + + // No work to be done if all are the same + if ( orig.size() == newTracks.size() && sameCount == orig.size() ) + return orig; + + return tosave; +} + + // taken from util/fileutils.cpp in kdevplatform bool removeDirectory( const QString& dir ) diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index c60bf89d4..fc2dcf4a1 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -24,6 +24,7 @@ #include #include #include +#include #define RESPATH ":/data/" @@ -88,6 +89,17 @@ namespace TomahawkUtils DLLEXPORT QString md5( const QByteArray& data ); DLLEXPORT bool removeDirectory( const QString& dir ); + /** + * This helper is designed to help "update" an existing playlist with a newer revision of itself. + * To avoid re-loading the whole playlist and re-resolving tracks that are the same in the old playlist, + * it goes through the new playlist and adds only new tracks. + * + * The new list of tracks is returned + * + * \return true if some changes were made, false if the new tracks are the same as the current tracks in \param orig + */ + DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks ); + DLLEXPORT void crash(); } diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index b33804d02..209855da1 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -107,7 +107,7 @@ ViewManager::ViewManager( QObject* parent ) m_widget->layout()->setMargin( 0 ); m_widget->layout()->setSpacing( 0 ); - connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::PlaylistInterface* ) ) ); + connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::playlistinterface_ptr ) ) ); connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); connect( m_infobar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) ); @@ -390,7 +390,7 @@ ViewManager::showSuperCollection() void -ViewManager::playlistInterfaceChanged( Tomahawk::PlaylistInterface* interface ) +ViewManager::playlistInterfaceChanged( Tomahawk::playlistinterface_ptr interface ) { playlist_ptr pl = playlistForInterface( interface ); if ( !pl.isNull() ) @@ -605,16 +605,16 @@ ViewManager::unlinkPlaylist() { if ( currentPlaylistInterface() ) { - disconnect( currentPlaylistInterface()->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), + disconnect( currentPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SIGNAL( numTracksChanged( unsigned int ) ) ); - disconnect( currentPlaylistInterface()->object(), SIGNAL( trackCountChanged( unsigned int ) ), + disconnect( currentPlaylistInterface().data(), SIGNAL( trackCountChanged( unsigned int ) ), this, SIGNAL( numShownChanged( unsigned int ) ) ); - disconnect( currentPlaylistInterface()->object(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), + disconnect( currentPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), this, SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) ); - disconnect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ), + disconnect( currentPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), this, SIGNAL( shuffleModeChanged( bool ) ) ); } } @@ -644,16 +644,16 @@ ViewManager::updateView() { if ( currentPlaylistInterface() ) { - connect( currentPlaylistInterface()->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), + connect( currentPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), SIGNAL( numTracksChanged( unsigned int ) ) ); - connect( currentPlaylistInterface()->object(), SIGNAL( trackCountChanged( unsigned int ) ), + connect( currentPlaylistInterface().data(), SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( numShownChanged( unsigned int ) ) ); - connect( currentPlaylistInterface()->object(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), + connect( currentPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) ); - connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ), + connect( currentPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), SIGNAL( shuffleModeChanged( bool ) ) ); m_infobar->setFilter( currentPlaylistInterface()->filter() ); @@ -824,7 +824,7 @@ ViewManager::pageForPlaylist(const playlist_ptr& pl) const ViewPage* -ViewManager::pageForInterface( Tomahawk::PlaylistInterface* interface ) const +ViewManager::pageForInterface( Tomahawk::playlistinterface_ptr interface ) const { for ( int i = 0; i < m_pageHistory.count(); i++ ) { @@ -838,13 +838,13 @@ ViewManager::pageForInterface( Tomahawk::PlaylistInterface* interface ) const return 0; } -PlaylistInterface* +Tomahawk::playlistinterface_ptr ViewManager::currentPlaylistInterface() const { if ( currentPage() ) return currentPage()->playlistInterface(); else - return 0; + return Tomahawk::playlistinterface_ptr(); } @@ -855,7 +855,7 @@ ViewManager::currentPage() const } Tomahawk::playlist_ptr -ViewManager::playlistForInterface( Tomahawk::PlaylistInterface* interface ) const +ViewManager::playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const { foreach ( QWeakPointer view, m_playlistViews.values() ) { @@ -865,12 +865,12 @@ ViewManager::playlistForInterface( Tomahawk::PlaylistInterface* interface ) cons } } - return playlist_ptr(); + return Tomahawk::playlist_ptr(); } Tomahawk::dynplaylist_ptr -ViewManager::dynamicPlaylistForInterface( Tomahawk::PlaylistInterface* interface ) const +ViewManager::dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr interface ) const { foreach ( QWeakPointer view, m_dynamicWidgets.values() ) { @@ -880,12 +880,12 @@ ViewManager::dynamicPlaylistForInterface( Tomahawk::PlaylistInterface* interface } } - return dynplaylist_ptr(); + return Tomahawk::dynplaylist_ptr(); } Tomahawk::collection_ptr -ViewManager::collectionForInterface( Tomahawk::PlaylistInterface* interface ) const +ViewManager::collectionForInterface( Tomahawk::playlistinterface_ptr interface ) const { foreach ( QWeakPointer view, m_collectionViews.values() ) { diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index 1a9b698b8..e61a201d4 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -70,7 +70,7 @@ public: static ViewManager* instance(); explicit ViewManager( QObject* parent = 0 ); - ~ViewManager(); + virtual ~ViewManager(); QWidget* widget() const { return m_widget; } InfoBar* infobar() const { return m_infobar; } @@ -82,9 +82,9 @@ public: bool isSuperCollectionVisible() const; bool isNewPlaylistPageVisible() const; - Tomahawk::PlaylistInterface* currentPlaylistInterface() const; + Tomahawk::playlistinterface_ptr currentPlaylistInterface() const; Tomahawk::ViewPage* currentPage() const; - Tomahawk::ViewPage* pageForInterface( Tomahawk::PlaylistInterface* interface ) const; + Tomahawk::ViewPage* pageForInterface( Tomahawk::playlistinterface_ptr interface ) const; Tomahawk::ViewPage* show( Tomahawk::ViewPage* page ); @@ -158,7 +158,7 @@ public slots: void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode ); void setShuffled( bool enabled ); - void playlistInterfaceChanged( Tomahawk::PlaylistInterface* ); + void playlistInterfaceChanged( Tomahawk::playlistinterface_ptr ); // called by the playlist creation dbcmds void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents ); @@ -179,9 +179,9 @@ private: void saveCurrentPlaylistSettings(); void loadCurrentPlaylistSettings(); - Tomahawk::playlist_ptr playlistForInterface( Tomahawk::PlaylistInterface* interface ) const; - Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::PlaylistInterface* interface ) const; - Tomahawk::collection_ptr collectionForInterface( Tomahawk::PlaylistInterface* interface ) const; + Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const; + Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr interface ) const; + Tomahawk::collection_ptr collectionForInterface( Tomahawk::playlistinterface_ptr interface ) const; QWidget* m_widget; InfoBar* m_infobar; diff --git a/src/libtomahawk/viewpage.h b/src/libtomahawk/viewpage.h index 72726f57e..9b0b0a199 100644 --- a/src/libtomahawk/viewpage.h +++ b/src/libtomahawk/viewpage.h @@ -25,7 +25,7 @@ #include "album.h" #include "utils/tomahawkutils.h" -#include +#include namespace Tomahawk { @@ -43,7 +43,7 @@ public: virtual ~ViewPage() {} virtual QWidget* widget() = 0; - virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0; virtual QString title() const = 0; diff --git a/src/libtomahawk/widgets/OverlayButton.cpp b/src/libtomahawk/widgets/OverlayButton.cpp index 3cdb88507..f2d5c09e8 100644 --- a/src/libtomahawk/widgets/OverlayButton.cpp +++ b/src/libtomahawk/widgets/OverlayButton.cpp @@ -20,12 +20,14 @@ #include #include +#include +#include #include "utils/logger.h" #define CORNER_ROUNDNESS 8.0 #define FADING_DURATION 500 -#define FONT_SIZE 16 +#define FONT_SIZE 12 #define OPACITY 0.70 @@ -34,7 +36,7 @@ OverlayButton::OverlayButton( QWidget* parent ) , m_opacity( 0.0 ) , m_parent( parent ) { - resize( 0, 26 ); + resize( 0, 28 ); setAttribute( Qt::WA_TranslucentBackground, true ); setOpacity( m_opacity ); @@ -78,8 +80,12 @@ OverlayButton::setText( const QString& text ) { m_text = text; - QFontMetrics fm( font() ); - resize( fm.width( text ) + 16, height() ); + QFont f( font() ); + f.setPixelSize( FONT_SIZE ); + f.setBold( true ); + + QFontMetrics fm( f ); + resize( fm.width( text ) + 24, height() ); } @@ -120,7 +126,13 @@ void OverlayButton::paintEvent( QPaintEvent* event ) { Q_UNUSED( event ); - QPoint corner( m_parent->contentsRect().width() - width() - 12, m_parent->height() - height() - 12 ); + + int scrollBarWidth = 0; + QAbstractScrollArea* scrollArea = qobject_cast( m_parent ); + if ( scrollArea && scrollArea->verticalScrollBar()->isVisible() ) + scrollBarWidth = scrollArea->verticalScrollBar()->width(); + + QPoint corner( m_parent->contentsRect().width() - width() - scrollBarWidth - 12, m_parent->height() - height() - 12 ); move( corner ); QPainter p( this ); @@ -141,25 +153,10 @@ OverlayButton::paintEvent( QPaintEvent* event ) // shrink to fit if needed QFont f( font() ); - f.setPointSize( FONT_SIZE ); + f.setPixelSize( FONT_SIZE ); f.setBold( true ); - QRectF textRect = r.adjusted( 8, 8, -8, -8 ); - qreal availHeight = textRect.height(); - - QFontMetricsF fm( f ); - qreal textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height(); - while ( textHeight > availHeight ) - { - if ( f.pointSize() <= 4 ) // don't try harder - break; - - f.setPointSize( f.pointSize() - 1 ); - fm = QFontMetricsF( f ); - textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height(); - } - p.setFont( f ); p.setPen( Qt::white ); - p.drawText( r.adjusted( 8, 8, -8, -8 ), text(), to ); + p.drawText( r, text(), to ); } diff --git a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp index f1f5147e3..0dbbf5be5 100644 --- a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp +++ b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp @@ -37,7 +37,7 @@ RecentlyPlayedPlaylistsModel::RecentlyPlayedPlaylistsModel( QObject* parent ) connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::QueuedConnection ); connect( TomahawkSettings::instance(), SIGNAL( recentlyPlayedPlaylistAdded( Tomahawk::playlist_ptr ) ), this, SLOT( plAdded( Tomahawk::playlist_ptr ) ) ); - connect( AudioEngine::instance(),SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ), Qt::QueuedConnection ); + connect( AudioEngine::instance(),SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ), Qt::QueuedConnection ); emit emptinessChanged( m_recplaylists.isEmpty() ); } @@ -60,7 +60,7 @@ RecentlyPlayedPlaylistsModel::loadFromSettings() { // qDebug() << "loading playlist" << playlist_guids[i]; - playlist_ptr pl = m_cached.value( playlist_guids[i], playlist_ptr() ); + playlist_ptr pl = m_cached.value( playlist_guids[i], Tomahawk::playlist_ptr() ); if( pl.isNull() ) pl = Tomahawk::Playlist::load( playlist_guids[i] ); if( pl.isNull() ) @@ -229,10 +229,13 @@ RecentlyPlayedPlaylistsModel::plAdded( const playlist_ptr& pl ) void -RecentlyPlayedPlaylistsModel::playlistChanged( Tomahawk::PlaylistInterface* pli ) +RecentlyPlayedPlaylistsModel::playlistChanged( Tomahawk::playlistinterface_ptr pli ) { // ARG - if( Playlist* pl = dynamic_cast< Playlist* >( pli ) ) { + if ( pli.isNull() ) + return; + + if ( Playlist *pl = dynamic_cast< Playlist* >( pli.data() ) ) { // look for it, qsharedpointer fail playlist_ptr ptr; foreach( const playlist_ptr& test, m_recplaylists ) { diff --git a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h index 2f0cad63d..7cd6fb169 100644 --- a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h +++ b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h @@ -44,8 +44,11 @@ public: signals: void emptinessChanged( bool isEmpty ); +public slots: + void sourceOnline(); + private slots: - void playlistChanged( Tomahawk::PlaylistInterface* ); + void playlistChanged( Tomahawk::playlistinterface_ptr ); void onSourceAdded( const Tomahawk::source_ptr& source ); void onPlaylistsRemoved( QList ); void loadFromSettings(); @@ -60,8 +63,6 @@ private: unsigned int m_maxPlaylists; bool m_waitingForSome; - public slots: - void sourceOnline(); }; #endif // RECENTLYPLAYEDPLAYLISTSMODEL_H diff --git a/src/libtomahawk/widgets/SocialPlaylistWidget.cpp b/src/libtomahawk/widgets/SocialPlaylistWidget.cpp index ea45f1aec..7cf54dd9e 100644 --- a/src/libtomahawk/widgets/SocialPlaylistWidget.cpp +++ b/src/libtomahawk/widgets/SocialPlaylistWidget.cpp @@ -85,7 +85,7 @@ SocialPlaylistWidget::SocialPlaylistWidget ( QWidget* parent ) connect( SourceList::instance(), SIGNAL( ready() ), SLOT( updateRecentTracks() ) ); 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( Tomahawk::PlaylistInterface* ) ), this, SLOT( updatePlaylists() ), Qt::QueuedConnection ); + connect( AudioEngine::instance() ,SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( updatePlaylists() ), Qt::QueuedConnection ); */ fetchFromDB(); } @@ -115,10 +115,10 @@ SocialPlaylistWidget::fetchFromDB() } -PlaylistInterface* +Tomahawk::playlistinterface_ptr SocialPlaylistWidget::playlistInterface() const { - return 0; + return Tomahawk::playlistinterface_ptr(); } diff --git a/src/libtomahawk/widgets/SocialPlaylistWidget.h b/src/libtomahawk/widgets/SocialPlaylistWidget.h index 50549c33c..e8f109bdb 100644 --- a/src/libtomahawk/widgets/SocialPlaylistWidget.h +++ b/src/libtomahawk/widgets/SocialPlaylistWidget.h @@ -55,7 +55,7 @@ public: ~SocialPlaylistWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QString title() const { return m_title; } virtual QString description() const { return m_description; } diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp index cad3c9785..0b70bb809 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp @@ -99,7 +99,7 @@ AlbumInfoWidget::~AlbumInfoWidget() } -PlaylistInterface* +Tomahawk::playlistinterface_ptr AlbumInfoWidget::playlistInterface() const { return ui->tracksView->playlistInterface(); diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h index 9c849ec0a..56ce5dc4e 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h @@ -28,7 +28,7 @@ #ifndef ALBUMINFOWIDGET_H #define ALBUMINFOWIDGET_H -#include +#include #include "playlistinterface.h" #include "viewpage.h" @@ -55,7 +55,7 @@ public: ~AlbumInfoWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QString title() const { return m_title; } virtual DescriptionType descriptionType(); diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp index daf9be42b..0bdcb51de 100644 --- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp @@ -46,7 +46,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* { ui->setupUi( this ); - m_plInterface = new MetaPlaylistInterface( this ); + m_plInterface = Tomahawk::playlistinterface_ptr( new MetaPlaylistInterface( this ) ); ui->albums->setFrameShape( QFrame::NoFrame ); ui->albums->setAttribute( Qt::WA_MacShowFocusRect, 0 ); @@ -97,12 +97,11 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* ArtistInfoWidget::~ArtistInfoWidget() { - delete m_plInterface; delete ui; } -PlaylistInterface* +Tomahawk::playlistinterface_ptr ArtistInfoWidget::playlistInterface() const { return m_plInterface; diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h index 72e5fb815..b851a7325 100644 --- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h +++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h @@ -68,7 +68,7 @@ public: void load( const Tomahawk::artist_ptr& artist ); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QString title() const { return m_title; } virtual QString description() const { return m_description; } @@ -107,7 +107,7 @@ private: TreeModel* m_relatedModel; TreeModel* m_albumsModel; PlaylistModel* m_topHitsModel; - MetaPlaylistInterface* m_plInterface; + Tomahawk::playlistinterface_ptr m_plInterface; OverlayButton* m_button; diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h index 6a312b5e3..a50bb1a31 100644 --- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h +++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h @@ -27,12 +27,12 @@ #include -class MetaPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface +class MetaPlaylistInterface : public Tomahawk::PlaylistInterface { Q_OBJECT public: explicit MetaPlaylistInterface( ArtistInfoWidget* w ) - : PlaylistInterface( this ) + : PlaylistInterface() , m_w( w ) { connect( m_w->ui->albums->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), @@ -53,9 +53,9 @@ public: // Any one is fine, we keep them all synched - virtual RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->repeatMode(); } + virtual RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->getPlaylistInterface()->repeatMode(); } - virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->shuffled(); } + virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->getPlaylistInterface()->shuffled(); } // Do nothing virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); } @@ -64,25 +64,26 @@ public: virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); } virtual int unfilteredTrackCount() const { return 0; } - virtual bool hasChildInterface( PlaylistInterface* other ) + virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr other ) { return ( m_w->ui->albums->playlistInterface() == other ) || ( m_w->ui->relatedArtists->playlistInterface() == other ) || ( m_w->ui->topHits->playlistInterface() == other ); } + public slots: virtual void setRepeatMode( RepeatMode mode ) { - m_w->ui->albums->proxyModel()->setRepeatMode( mode ); - m_w->ui->relatedArtists->proxyModel()->setRepeatMode( mode ); - m_w->ui->topHits->proxyModel()->setRepeatMode( mode ); + m_w->ui->albums->proxyModel()->getPlaylistInterface()->setRepeatMode( mode ); + m_w->ui->relatedArtists->proxyModel()->getPlaylistInterface()->setRepeatMode( mode ); + m_w->ui->topHits->proxyModel()->getPlaylistInterface()->setRepeatMode( mode ); } virtual void setShuffled( bool enabled ) { - m_w->ui->albums->proxyModel()->setShuffled( enabled ); - m_w->ui->relatedArtists->proxyModel()->setShuffled( enabled ); - m_w->ui->topHits->proxyModel()->setShuffled( enabled ); + m_w->ui->albums->proxyModel()->getPlaylistInterface()->setShuffled( enabled ); + m_w->ui->relatedArtists->proxyModel()->getPlaylistInterface()->setShuffled( enabled ); + m_w->ui->topHits->proxyModel()->getPlaylistInterface()->setShuffled( enabled ); } signals: diff --git a/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h index 7d849004c..eb1817aba 100644 --- a/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h +++ b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h @@ -44,7 +44,7 @@ public: ~SourceInfoWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return m_title; } virtual QString description() const { return m_description; } diff --git a/src/libtomahawk/widgets/newplaylistwidget.h b/src/libtomahawk/widgets/newplaylistwidget.h index 8d99a154c..56bfa9134 100644 --- a/src/libtomahawk/widgets/newplaylistwidget.h +++ b/src/libtomahawk/widgets/newplaylistwidget.h @@ -19,8 +19,8 @@ #ifndef NEWPLAYLISTWIDGET_H #define NEWPLAYLISTWIDGET_H -#include -#include +#include +#include #include "playlistinterface.h" #include "viewpage.h" @@ -44,7 +44,7 @@ public: ~NewPlaylistWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual QString title() const { return tr( "Create a new playlist" ); } virtual QString description() const { return QString(); } diff --git a/src/libtomahawk/widgets/searchwidget.h b/src/libtomahawk/widgets/searchwidget.h index 9c00a3469..b16f3611f 100644 --- a/src/libtomahawk/widgets/searchwidget.h +++ b/src/libtomahawk/widgets/searchwidget.h @@ -46,7 +46,7 @@ public: ~SearchWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } virtual bool isTemporaryPage() const { return true; } virtual QString title() const { return QString( tr( "Search: %1" ) ).arg( m_search ); } diff --git a/src/libtomahawk/widgets/welcomewidget.cpp b/src/libtomahawk/widgets/welcomewidget.cpp index 5ac2f5581..2dd214e60 100644 --- a/src/libtomahawk/widgets/welcomewidget.cpp +++ b/src/libtomahawk/widgets/welcomewidget.cpp @@ -20,7 +20,7 @@ #include "welcomewidget.h" #include "ui_welcomewidget.h" -#include +#include #include "viewmanager.h" #include "sourcelist.h" @@ -98,7 +98,7 @@ WelcomeWidget::~WelcomeWidget() } -PlaylistInterface* +Tomahawk::playlistinterface_ptr WelcomeWidget::playlistInterface() const { return ui->tracksView->playlistInterface(); @@ -265,12 +265,14 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QTextOption to; to.setAlignment( Qt::AlignCenter ); QFont font = opt.font; -#ifdef Q_WS_MAC - font.setPointSize( font.pointSize() - 2 ); -#endif + font.setPixelSize( 10 ); QFont boldFont = font; boldFont.setBold( true ); + boldFont.setPixelSize( 11 ); + + QFont figFont = boldFont; + figFont.setPixelSize( 10 ); QPixmap icon; RecentlyPlayedPlaylistsModel::PlaylistTypes type = (RecentlyPlayedPlaylistsModel::PlaylistTypes)index.data( RecentlyPlayedPlaylistsModel::PlaylistTypeRole ).toInt(); @@ -289,6 +291,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, if ( type != RecentlyPlayedPlaylistsModel::Station ) { painter->save(); + painter->setFont( figFont ); QString tracks = index.data( RecentlyPlayedPlaylistsModel::TrackCountRole ).toString(); int width = painter->fontMetrics().width( tracks ); // int bottomEdge = pixmapRect @@ -302,7 +305,6 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QColor figColor( 153, 153, 153 ); painter->setPen( figColor ); painter->setBrush( figColor ); - painter->setFont( boldFont ); TomahawkUtils::drawBackgroundAndNumbers( painter, tracks, rect ); painter->restore(); @@ -314,14 +316,12 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QRect r( option.rect.width() - avatar.width() - 10, option.rect.top() + option.rect.height()/2 - avatar.height()/2, avatar.width(), avatar.height() ); painter->drawPixmap( r, avatar ); - QFont font2 = font; - font2.setPointSize( font2.pointSize() - 1 ); - painter->setFont( font2 ); + painter->setFont( font ); QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName(); if ( author.contains( "@" ) ) author = author.mid( 0, author.indexOf( '@' ) ); - const int w = painter->fontMetrics().width( author ); + const int w = painter->fontMetrics().width( author ) + 2; QRect avatarNameRect( opt.rect.width() - 10 - w, r.bottom(), w, opt.rect.bottom() - r.bottom() ); painter->drawText( avatarNameRect, author, QTextOption( Qt::AlignCenter ) ); diff --git a/src/libtomahawk/widgets/welcomewidget.h b/src/libtomahawk/widgets/welcomewidget.h index bbbb754bf..296fecfba 100644 --- a/src/libtomahawk/widgets/welcomewidget.h +++ b/src/libtomahawk/widgets/welcomewidget.h @@ -81,10 +81,10 @@ Q_OBJECT public: WelcomeWidget( QWidget* parent = 0 ); - ~WelcomeWidget(); + virtual ~WelcomeWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QString title() const { return tr( "Welcome to Tomahawk" ); } virtual QString description() const { return QString(); } diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp index cb0d947f4..062139050 100644 --- a/src/libtomahawk/widgets/whatshotwidget.cpp +++ b/src/libtomahawk/widgets/whatshotwidget.cpp @@ -52,7 +52,6 @@ static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" ); WhatsHotWidget::WhatsHotWidget( QWidget* parent ) : QWidget( parent ) , ui( new Ui::WhatsHotWidget ) - , m_playlistInterface( 0 ) , m_sortedProxy( 0 ) , m_workerThread( 0 ) { @@ -94,7 +93,7 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent ) ui->artistsViewLeft->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->artistsViewLeft->header()->setVisible( false ); - m_playlistInterface = new ChartsPlaylistInterface( this ); + m_playlistInterface = Tomahawk::playlistinterface_ptr( new ChartsPlaylistInterface( this ) ); m_workerThread = new QThread( this ); m_workerThread->start(); @@ -112,12 +111,12 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent ) WhatsHotWidget::~WhatsHotWidget() { m_workerThread->exit(0); - delete m_playlistInterface; + m_playlistInterface.clear(); delete ui; } -PlaylistInterface* +Tomahawk::playlistinterface_ptr WhatsHotWidget::playlistInterface() const { return m_playlistInterface; diff --git a/src/libtomahawk/widgets/whatshotwidget.h b/src/libtomahawk/widgets/whatshotwidget.h index 5df378752..1cfcd0248 100644 --- a/src/libtomahawk/widgets/whatshotwidget.h +++ b/src/libtomahawk/widgets/whatshotwidget.h @@ -19,9 +19,9 @@ #ifndef WHATSHOTWIDGET_H #define WHATSHOTWIDGET_H -#include -#include -#include +#include +#include +#include #include "playlistinterface.h" #include "infosystem/infosystem.h" @@ -31,7 +31,6 @@ #include "dllmacro.h" -class ChartsPlaylistInterface; class QSortFilterProxyModel; class QStandardItemModel; class QStandardItem; @@ -49,6 +48,7 @@ namespace Ui namespace Tomahawk { class ChartDataLoader; + class ChartsPlaylistInterface; } /** @@ -64,7 +64,7 @@ public: ~WhatsHotWidget(); virtual QWidget* widget() { return this; } - virtual Tomahawk::PlaylistInterface* playlistInterface() const; + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual QString title() const { return tr( "Charts" ); } virtual QString description() const { return QString(); } @@ -101,7 +101,7 @@ private: QStandardItem* parseNode( QStandardItem* parentItem, const QString &label, const QVariant &data ); Ui::WhatsHotWidget *ui; - ChartsPlaylistInterface* m_playlistInterface; + Tomahawk::playlistinterface_ptr m_playlistInterface; QStandardItemModel* m_crumbModelLeft; QSortFilterProxyModel* m_sortedProxy; @@ -119,7 +119,7 @@ private: QSet< QString > m_queuedFetches; QTimer* m_timer; - friend class ChartsPlaylistInterface; + friend class Tomahawk::ChartsPlaylistInterface; }; #endif // WHATSHOTWIDGET_H diff --git a/src/libtomahawk/widgets/whatshotwidget_p.h b/src/libtomahawk/widgets/whatshotwidget_p.h index e4e3d8dc4..b9602ae94 100644 --- a/src/libtomahawk/widgets/whatshotwidget_p.h +++ b/src/libtomahawk/widgets/whatshotwidget_p.h @@ -28,31 +28,33 @@ #include -class ChartsPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface +namespace Tomahawk +{ + +class ChartsPlaylistInterface : public Tomahawk::PlaylistInterface { Q_OBJECT public: explicit ChartsPlaylistInterface( WhatsHotWidget* w ) - : PlaylistInterface( this ) + : PlaylistInterface() , m_w( w ) { - connect( m_w->ui->tracksViewLeft->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), + connect( m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) ); - connect( m_w->ui->artistsViewLeft->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), + connect( m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ), SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) ); - connect( m_w->ui->tracksViewLeft->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ), + connect( m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), SLOT( anyShuffleChanged( bool ) ) ); - connect( m_w->ui->artistsViewLeft->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ), + connect( m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), SLOT( anyShuffleChanged( bool ) ) ); } virtual ~ChartsPlaylistInterface() {} - // Any one is fine, we keep them all synched - virtual RepeatMode repeatMode() const { return m_w->ui->tracksViewLeft->proxyModel()->repeatMode(); } + virtual RepeatMode repeatMode() const { return m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->repeatMode(); } - virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->shuffled(); } + virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->shuffled(); } // Do nothing virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); } @@ -61,23 +63,24 @@ public: virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); } virtual int unfilteredTrackCount() const { return 0; } - virtual bool hasChildInterface( PlaylistInterface* other ) + virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr other ) { return m_w->ui->tracksViewLeft->playlistInterface() == other || m_w->ui->artistsViewLeft->playlistInterface() == other; } + public slots: virtual void setRepeatMode( RepeatMode mode ) { - m_w->ui->tracksViewLeft->proxyModel()->setRepeatMode( mode ); - m_w->ui->artistsViewLeft->proxyModel()->setRepeatMode( mode ); + m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->setRepeatMode( mode ); + m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface()->setRepeatMode( mode ); } virtual void setShuffled( bool enabled ) { - m_w->ui->tracksViewLeft->proxyModel()->setShuffled( enabled ); - m_w->ui->artistsViewLeft->proxyModel()->setShuffled( enabled ); + m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->setShuffled( enabled ); + m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface()->setShuffled( enabled ); } signals: @@ -104,4 +107,6 @@ private: }; +} //ns + #endif diff --git a/src/resolversmodel.cpp b/src/resolversmodel.cpp index b27e00791..c38b02b44 100644 --- a/src/resolversmodel.cpp +++ b/src/resolversmodel.cpp @@ -208,7 +208,7 @@ ResolversModel::addInstalledResolvers() QDir appDir( qApp->applicationDirPath() ); QDir libDir( CMAKE_INSTALL_PREFIX "/lib" ); - QDir libexecDir( CMAKE_INSTALL_LIBEXECDIR ); + QDir libexecDir( CMAKE_INSTALL_FULL_LIBEXECDIR ); QDir lib64Dir( appDir ); lib64Dir.cdUp(); diff --git a/src/sip/jabber/CMakeLists.txt b/src/sip/jabber/CMakeLists.txt new file mode 100644 index 000000000..3332dea97 --- /dev/null +++ b/src/sip/jabber/CMakeLists.txt @@ -0,0 +1,71 @@ +project( tomahawk ) + +include( ${QT_USE_FILE} ) +add_definitions( ${QT_DEFINITIONS} ) +add_definitions( -DQT_PLUGIN ) +add_definitions( -DQT_SHARED ) +add_definitions( -DSIPDLLEXPORT_PRO ) + +set( jabberSources + jabber.cpp + tomahawksipmessage.cpp + tomahawksipmessagefactory.cpp +) +set( jabberSourcesGui + avatarmanager.cpp + xmlconsole.cpp +) + +set( jabberHeaders + jabber.h +) +set( jabberHeadersGui + avatarmanager.h + xmlconsole.h +) + +set( jabberUI + configwidget.ui + xmlconsole.ui +) + +if(BUILD_GUI) + list(APPEND jabberSources ${jabberSourcesGui}) + list(APPEND jabberHeaders ${jabberHeadersGui}) +endif() + +include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. + ${QT_INCLUDE_DIR} + ${LIBJREEN_INCLUDE_DIR} +) + +qt4_add_resources( RC_SRCS "resources.qrc" ) +qt4_wrap_ui( jabberUI_H ${jabberUI} ) +qt4_wrap_cpp( jabberMoc ${jabberHeaders} ) +add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} ${jabberUI_H} ${RC_SRCS} ) + +IF( WIN32 ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + "secur32.dll" + "crypt32.dll" + ${TOMAHAWK_LIBRARIES} +) +ENDIF( WIN32 ) + +target_link_libraries( tomahawk_sipjabber + ${QT_LIBRARIES} + ${LIBJREEN_LIBRARY} + ${OS_SPECIFIC_LINK_LIBRARIES} + tomahawklib +) + +IF( APPLE ) +# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) +ENDIF( APPLE ) + +install( TARGETS tomahawk_sipjabber DESTINATION ${CMAKE_INSTALL_LIBDIR} ) + +if(BUILD_GUI) + add_subdirectory(googlewrapper) +endif() diff --git a/src/sip/jabber/googlewrapper/CMakeLists.txt b/src/sip/jabber/googlewrapper/CMakeLists.txt new file mode 100644 index 000000000..ba0e11b55 --- /dev/null +++ b/src/sip/jabber/googlewrapper/CMakeLists.txt @@ -0,0 +1,32 @@ + +# fake google plugin + +set( googleHeaders + ../jabber.h + ../avatarmanager.h + ../xmlconsole.h + googlewrapper.h ) + +set( googleSources + ../jabber.cpp + ../tomahawksipmessage.cpp + ../tomahawksipmessagefactory.cpp + ../avatarmanager.cpp + ../xmlconsole.cpp + googlewrapper.cpp ) + +add_definitions(-DGOOGLE_WRAPPER) + +qt4_add_resources( RCX_SRCS "resources.qrc" ) + +qt4_wrap_cpp( googleMoc ${googleHeaders} ) +add_library( tomahawk_sipgoogle SHARED ${googleSources} ${googleMoc} ${googleMoc} ${RCX_SRCS} ) + +target_link_libraries( tomahawk_sipgoogle + ${QT_LIBRARIES} + ${LIBJREEN_LIBRARY} + ${OS_SPECIFIC_LINK_LIBRARIES} + tomahawklib +) + +install( TARGETS tomahawk_sipgoogle DESTINATION ${CMAKE_INSTALL_LIBDIR} ) diff --git a/src/sourcetree/items/historyitem.cpp b/src/sourcetree/items/historyitem.cpp index 09aaa2b6a..5b6c73b98 100644 --- a/src/sourcetree/items/historyitem.cpp +++ b/src/sourcetree/items/historyitem.cpp @@ -33,7 +33,6 @@ using namespace Tomahawk; HistoryItem::HistoryItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, int peerSortValue ) : GroupItem( model, parent, text, peerSortValue ) { - connect( this, SIGNAL( toggleExpandRequest( SourceTreeItem* ) ), model, SLOT( itemToggleExpandRequest( SourceTreeItem* ) ) ); connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage* ) ), SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) ); } @@ -43,13 +42,6 @@ HistoryItem::~HistoryItem() } -void -HistoryItem::activate() -{ - emit toggleExpandRequest( this ); -} - - void HistoryItem::tempPageActivated( Tomahawk::ViewPage* v ) { diff --git a/src/sourcetree/items/historyitem.h b/src/sourcetree/items/historyitem.h index 7406d4e84..f4c3699b5 100644 --- a/src/sourcetree/items/historyitem.h +++ b/src/sourcetree/items/historyitem.h @@ -38,12 +38,6 @@ public: HistoryItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, int peerSortValue = 0 ); virtual ~HistoryItem(); -public slots: - virtual void activate(); - -signals: - void activated(); - private slots: void tempPageActivated( Tomahawk::ViewPage* ); void temporaryPageDestroyed(); diff --git a/src/sourcetree/sourcedelegate.cpp b/src/sourcetree/sourcedelegate.cpp index ea69300b4..ad0fd4855 100644 --- a/src/sourcetree/sourcedelegate.cpp +++ b/src/sourcetree/sourcedelegate.cpp @@ -140,6 +140,8 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& QFont normal = painter->font(); QFont bold = painter->font(); bold.setBold( true ); + QFont figFont = bold; + figFont.setPixelSize( 10 ); SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >(); SourceItem* colItem = qobject_cast< SourceItem* >( item ); @@ -153,7 +155,7 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& if ( status && colItem && !colItem->source().isNull() ) { tracks = QString::number( colItem->source()->trackCount() ); - figWidth = painter->fontMetrics().width( tracks ); + figWidth = QFontMetrics( figFont ).width( tracks ); name = colItem->source()->friendlyName(); } @@ -231,10 +233,8 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& QRect figRect = option.rect.adjusted( option.rect.width() - figWidth - 8, 0, -13, -option.rect.height() + 16 ); int hd = ( option.rect.height() - figRect.height() ) / 2; figRect.adjust( 0, hd, 0, hd ); -#ifdef Q_WS_WIN - figRect.adjust( -3, 0, 3, 0 ); -#endif - painter->setFont( bold ); + + painter->setFont( figFont ); QColor figColor( 167, 183, 211 ); painter->setPen( figColor ); diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index abacd799b..242315b4b 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -84,8 +84,8 @@ SourceTreeView::SourceTreeView( QWidget* parent ) // setAnimated( true ); m_delegate = new SourceDelegate( this ); - connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ), Qt::QueuedConnection ); - connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ), Qt::QueuedConnection ); + connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) ); + connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) ); setItemDelegate( m_delegate ); diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 925783e91..4f63d79fc 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -403,6 +403,7 @@ TomahawkApp::registerMetaTypes() qRegisterMetaType< Tomahawk::source_ptr >("Tomahawk::source_ptr"); qRegisterMetaType< Tomahawk::dyncontrol_ptr >("Tomahawk::dyncontrol_ptr"); qRegisterMetaType< Tomahawk::playlist_ptr >("Tomahawk::playlist_ptr"); + qRegisterMetaType< Tomahawk::playlistinterface_ptr >("Tomahawk::playlistinterface_ptr"); qRegisterMetaType< Tomahawk::dynplaylist_ptr >("Tomahawk::dynplaylist_ptr"); qRegisterMetaType< Tomahawk::geninterface_ptr >("Tomahawk::geninterface_ptr"); qRegisterMetaType< QList >("QList"); diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp index 5fa9a3535..992bb3f04 100644 --- a/src/tomahawkwindow.cpp +++ b/src/tomahawkwindow.cpp @@ -224,7 +224,7 @@ TomahawkWindow::setupSideBar() m_queueModel->setStyle( PlaylistModel::Short ); m_queueView->queue()->setPlaylistModel( m_queueModel ); m_queueView->queue()->playlistModel()->setReadOnly( false ); - AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() ); + AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel()->getPlaylistInterface() ); m_sidebar->addWidget( m_searchWidget ); m_sidebar->addWidget( m_sourcetree ); diff --git a/thirdparty/jreen b/thirdparty/jreen deleted file mode 160000 index 2957d0ff0..000000000 --- a/thirdparty/jreen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2957d0ff03d9561af8afc4bd3a45947392868875 diff --git a/thirdparty/libportfwd/CMakeLists.txt b/thirdparty/libportfwd/CMakeLists.txt index 7c53626fc..d97f14ee8 100644 --- a/thirdparty/libportfwd/CMakeLists.txt +++ b/thirdparty/libportfwd/CMakeLists.txt @@ -48,10 +48,11 @@ ENDIF() INSTALL( TARGETS tomahawk_portfwd RUNTIME DESTINATION bin - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} BUNDLE DESTINATION library ) + #INSTALL(FILES include/portfwd/portfwddllmacro.h include/portfwd/portfwd.h DESTINATION include/portfwd) #ADD_EXECUTABLE(portfwd-demo